Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, source=None, mutation_id=ALL, dict_synonyms=None, filename=None, config=None, index=0):
self.index = index
self.remove_newline_at_end = False
self._source = None
self._set_source(source)
self.mutation_id = mutation_id
self.performed_mutation_ids = []
assert isinstance(mutation_id, RelativeMutationID)
self.current_line_index = 0
self.filename = filename
self.stack = []
self.dict_synonyms = (dict_synonyms or []) + ['dict']
self._source_by_line_number = None
self._pragma_no_mutate_lines = None
self._path_by_line = None
self.config = config
self.skip = False
self.line = line
self.index = index
self.line_number = line_number
self.filename = filename
def __repr__(self):
return 'MutationID(line="{}", index={}, line_number={}, filename={})'.format(self.line, self.index, self.line_number, self.filename)
def __eq__(self, other):
return (self.line, self.index, self.line_number) == (other.line, other.index, other.line_number)
def __hash__(self):
return hash((self.line, self.index, self.line_number))
ALL = RelativeMutationID(filename='%all%', line='%all%', index=-1, line_number=-1)
class InvalidASTPatternException(Exception):
pass
class ASTPattern(object):
def __init__(self, source, **definitions):
if definitions is None:
definitions = {}
source = source.strip()
self.definitions = definitions
self.module = parse(source)
def mutation_id_of_current_index(self):
return RelativeMutationID(filename=self.filename, line=self.current_source_line, index=self.index, line_number=self.current_line_index)