def _get_view_results(self, view): """ Get the results based on the view """ if view == TREE_VIEW: result = self.tree else: result = TextResult(tree_results=self.tree) result.cleanup() # clean up text-style result dictionary return result
def __init__(self, t1, t2, ignore_order=False, report_repetition=False, significant_digits=None, exclude_paths=set(), exclude_types=set(), verbose_level=1, view='text', **kwargs): # if kwargs: # raise ValueError(( # "The following parameter(s) are not valid: %s\n" # "The valid parameters are ignore_order, report_repetition, significant_digits," # "exclude_paths, exclude_types, verbose_level and view.") % ', '.join(kwargs.keys())) self.ignore_order = ignore_order self.report_repetition = report_repetition self.exclude_paths = set(exclude_paths) self.exclude_types = set(exclude_types) self.exclude_types_tuple = tuple( exclude_types) # we need tuple for checking isinstance self.hashes = {} self.accept_later = kwargs.get('accept_later') self.accept_earlier = kwargs.get('accept_earlier') self.accept_new = kwargs.get('accept_new') self.result_dict = dict() if significant_digits is not None and significant_digits < 0: raise ValueError( "significant_digits must be None or a non-negative integer") self.significant_digits = significant_digits self.tree = TreeResult() Verbose.level = verbose_level root = DiffLevel(t1, t2) self.__diff(root, parents_ids=frozenset({id(t1)})) self.tree.cleanup() if view == 'tree': self.update(self.tree) del self.tree else: result_text = TextResult(tree_results=self.tree) result_text.cleanup() # clean up text-style result dictionary self.update( result_text ) # be compatible to DeepDiff 2.x if user didn't specify otherwise self.result_text = result_text self.result_dict = self.dict_result()
def __init__(self, t1, t2, ignore_order=False, report_repetition=False, significant_digits=None, exclude_paths=set(), exclude_types=set(), verbose_level=1, view='text', **kwargs): if kwargs: raise ValueError(( "The following parameter(s) are not valid: %s\n" "The valid parameters are ignore_order, report_repetition, significant_digits," "exclude_paths, exclude_types, verbose_level and view.") % ', '.join(kwargs.keys())) self.ignore_order = ignore_order self.report_repetition = report_repetition self.exclude_paths = set(exclude_paths) self.exclude_types = set(exclude_types) self.exclude_types_tuple = tuple( exclude_types) # we need tuple for checking isinstance self.hashes = {} if significant_digits is not None and significant_digits < 0: raise ValueError( "significant_digits must be None or a non-negative integer") self.significant_digits = significant_digits self.tree = TreeResult() Verbose.level = verbose_level root = DiffLevel(t1, t2) self.__diff(root, parents_ids=frozenset({id(t1)})) self.tree.cleanup() if view == 'tree': self.update(self.tree) del self.tree else: result_text = TextResult(tree_results=self.tree) result_text.cleanup() # clean up text-style result dictionary self.update( result_text ) # be compatible to DeepDiff 2.x if user didn't specify otherwise