utils Package¶
utils
Package¶
A collections of utils for fastr (command line tools or non-core functionality)
compare
Module¶
Module to compare various fastr specific things such as a execution directory or a reference directory.
-
fastr.utils.compare.
compare_set
(set1, set2, path, sub_compare_func, f_args=None, f_kwargs=None)[source]¶ Compare two sets and dispatch each item to a sub comparison function
Parameters: - set1 (Iterable) – first set of items
- set2 (Iterable) – second set of items
- path (str) – identifier of the data location
- sub_compare_func – function to apply to items
- f_args – args to pass to sub_compare_func
- f_kwargs – kwargs to pass to sub_compare_func
Returns: generator that iterates over the differences
Return type: generator
dicteq
Module¶
Some helper function to compare dictionaries and find the parts of the dict that are different. This is mostly to help in debugging.
-
fastr.utils.dicteq.
dicteq
(self, other)[source]¶ Compare two dicts for equality
Parameters: - self – the first object to compare
- other – the oth
Returns:
-
fastr.utils.dicteq.
diffdict
(self, other, path=None, visited=None)[source]¶ Find the differences in two dictionaries.
Parameters: Returns: list of messages indicating the differences
Return type:
-
fastr.utils.dicteq.
diffobj
(self, other, path=None, visited=None)[source]¶ Compare two objects by comparing their __dict__ entries
Parameters: - self – the first object to compare
- other – other objects to compare
- path (list) – the path for nested dicts (too keep track of recursion)
Returns: list of messages
Return type:
-
fastr.utils.dicteq.
diffobj_str
(self, other)[source]¶ Compare two objects by comparing their __dict__ entries, but returns the differences in a single string ready for logging.
Parameters: - self – the first object to compare
- other – other object to compare to
Returns: the description of the differences
Return type: