Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _from_tree_repetition_change(self, tree):
if 'repetition_change' in tree:
for change in tree['repetition_change']:
path = change.path(force=FORCE_DEFAULT)
self['repetition_change'][path] = RemapDict(change.additional[
'repetition'])
self['repetition_change'][path]['value'] = change.t1
def __str__(self):
return "Error: NotHashed" # pragma: no cover
not_hashed = NotHashed()
class Repetition(object):
def __repr__(self):
return "Repetition" # pragma: no cover
def __str__(self):
return "Repetition" # pragma: no cover
repetition = Repetition()
class ResultDict(RemapDict):
def cleanup(self):
"""
Remove empty keys from this object. Should always be called after the result is final.
:return:
"""
empty_keys = [k for k, v in getattr(self, items)() if not v]
for k in empty_keys:
del self[k]
class LevelContent(object):
"""
Represents an original object tree's content at this level.
DiffLevels have two of those because they contain two object trees
(one for the left side or "t1" and one for the right side or "t2")
def _from_tree_type_changes(self, tree):
if 'type_changes' in tree:
for change in tree['type_changes']:
remap_dict = RemapDict({
'old_type': type(change.t1),
'new_type': type(change.t2)
})
self['type_changes'][change.path(
force=FORCE_DEFAULT)] = remap_dict
if Verbose.level:
remap_dict.update(old_value=change.t1, new_value=change.t2)
def _from_tree_type_changes(self, tree):
if 'type_changes' in tree:
for change in tree['type_changes']:
remap_dict = RemapDict({
'old_type': type(change.t1),
'new_type': type(change.t2)
})
self['type_changes'][change.path(
force=FORCE_DEFAULT)] = remap_dict
if Verbose.level:
remap_dict.update(old_value=change.t1, new_value=change.t2)
def __str__(self):
return "Error: NotHashed" # pragma: no cover
not_hashed = NotHashed()
class Repetition(object):
def __repr__(self):
return "Repetition" # pragma: no cover
def __str__(self):
return "Repetition" # pragma: no cover
repetition = Repetition()
class ResultDict(RemapDict):
def cleanup(self):
"""
Remove empty keys from this object. Should always be called after the result is final.
:return:
"""
empty_keys = [k for k, v in getattr(self, items)() if not v]
for k in empty_keys:
del self[k]
class DiffTreeResult(ResultDict):
def __init__(self):
for key in DIFF_REPORT_KEYS:
self[key] = set()
def _format_diff_result(dr):
"""Formats diff result per yaml_safedump parsing."""
if isinstance(dr, dict):
for k, v in dr.items():
if isinstance(v, RemapDict):
v = dict(v)
dr.update({k: v})
if isinstance(v, type):
dr.update({k: str(v)})
if isinstance(v, dict):
_format_diff_result(v)
return dr
def _from_tree_repetition_change(self, tree):
if 'repetition_change' in tree:
for change in tree['repetition_change']:
path = change.path(force=FORCE_DEFAULT)
self['repetition_change'][path] = RemapDict(change.additional[
'repetition'])
self['repetition_change'][path]['value'] = change.t1