toolchest.hash¶
- toolchest.hash.generate_hash(list_to_hash, validator=<function validate_string>)[source]¶
Takes a list of strings in any order, sorts them for consistency, and generates a cryptographic hash to provide a unique representation of this combination of strings.
- Parameters
list_to_hash (list) – List of Strings to turn into a hash
validator (func) – A function to use to validate the format of items in the list of Strings. This function should throw a ValueError if the pattern does not match.
- Returns
A String that is a hash of the passed in list.
- Raises
ValueError – If the passed in list cannot be validated with the passed in validator, a ValueError is thrown.
toolchest.introspect¶
Methods related to introspection of a class
- toolchest.introspect.build_attrs(instance)[source]¶
Build a dict of attributes on a given instance
- Parameters
instance – An instance of some class
- Returns
Dict of all object attributes that are properties
toolchest.strutil¶
- toolchest.strutil.nym(arg)[source]¶
This is for allowing case and quote flexibility for strings when searching dictionaries or other data sets based on user input (esp. from the command line) where the likelihood of key collisions is low. For example, if we want to search a dictionary, we’d check the nym of the value provided with the nym of the key to see if they match. This should not be used when likelihood of collisions is high. (Origin: Greek word meaning “name”)
- Parameters
arg (string) – A string to create the nym for
- Returns
A lower-case string with whitespace swapped to _
- Return type
ret (string)
toolchest.yaml¶
Yaml related tools
- class toolchest.yaml.IndentDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]¶
Bases:
yaml.dumper.Dumper
Custom yaml dumper to ensure elements are indented