Utils¶
Data containers and other utilities.
-
class
openxc.utils.
AgingData
¶ Mixin to associate a class with a time of birth.
-
age
¶ Return the age of the data in seconds.
-
-
class
openxc.utils.
Range
(minimum, maximum)¶ Encapsulates a ranged defined by a min and max numerical value.
-
spread
¶ Returns the spread between this Range’s min and max.
-
within_range
(value)¶ Returns True if the value is between this Range, inclusive.
-
-
openxc.utils.
dict_raise_on_duplicates
(ordered_pairs)¶ Reject duplicate keys.
-
openxc.utils.
fatal_error
(message)¶
-
openxc.utils.
find_file
(filename, search_paths)¶
-
openxc.utils.
load_json_from_search_path
(filename, search_paths)¶
-
openxc.utils.
merge
(a, b)¶ Merge two deep dicts non-destructively
Uses a stack to avoid maximum recursion depth exceptions
>>> a = {'a': 1, 'b': {1: 1, 2: 2}, 'd': 6} >>> b = {'c': 3, 'b': {2: 7}, 'd': {'z': [1, 2, 3]}} >>> c = merge(a, b) >>> from pprint import pprint; pprint(c) {'a': 1, 'b': {1: 1, 2: 7}, 'c': 3, 'd': {'z': [1, 2, 3]}}
-
openxc.utils.
quacks_like_dict
(object)¶ Check if object is dict-like
-
openxc.utils.
quacks_like_list
(object)¶ Check if object is list-like