module documentation

Generic functions.

Class AnnotatingDecorator A decorator for storing function attributes.
Class ContextWeakrefMixin Undocumented
Class DynamicVar A dynamically scoped variable.
Exception UsageError Raise this for top-level usage errors.
Function concat_tuples Undocumented
Function format_version Format a version tuple into a dotted version string.
Function invert_dict Invert a dictionary.
Function list_startswith Like str.startswith, but for lists.
Function list_strip_prefix Remove prefix, if it's there.
Function maybe_truncate Truncate long strings (and append '...'), but leave short strings alone.
Function native_str Convert a bytes object to the native str type.
Function numeric_sort_key Undocumented
Function pretty_conjunction Pretty-print a conjunction. Use parentheses as necessary.
Function pretty_dnf Pretty-print a disjunctive normal form (disjunction of conjunctions).
Function strip_prefix Strip off prefix if it exists.
Function unique_list Return a unique list from an iterable, preserving order.
Function validate_version Raise an exception if the python version is unsupported.
Function version_from_string Parse a version string like "3.7" into a tuple.
Function _arg_names Return the argument names of a function.
Function _validate_python_version_upper_bound Undocumented
Constant _VALIDATE_PYTHON_VERSION_UPPER_BOUND Undocumented
def concat_tuples(tuples): (source)

Undocumented

def format_version(python_version): (source)

Format a version tuple into a dotted version string.

def invert_dict(d): (source)

Invert a dictionary. Converts a dictionary (mapping strings to lists of strings) to a dictionary that maps into the other direction. Arguments: d: Dictionary to be inverted Returns: A dictionary n with the property that if "y in d[x]", then "x in n[y]".

def list_startswith(l, prefix): (source)

Like str.startswith, but for lists.

def list_strip_prefix(l, prefix): (source)

Remove prefix, if it's there.

def maybe_truncate(s, length=30): (source)

Truncate long strings (and append '...'), but leave short strings alone.

def native_str(s: Union[str, bytes], errors: str = 'strict') -> str: (source)

Convert a bytes object to the native str type.

def numeric_sort_key(s): (source)

Undocumented

def pretty_conjunction(conjunction): (source)

Pretty-print a conjunction. Use parentheses as necessary. E.g. ["a", "b"] -> "(a & b)" Args: conjunction: List of strings. Returns: A pretty-printed string.

def pretty_dnf(dnf): (source)

Pretty-print a disjunctive normal form (disjunction of conjunctions). E.g. [["a", "b"], ["c"]] -> "(a & b) | c". Args: dnf: A list of list of strings. (Disjunction of conjunctions of strings) Returns: A pretty-printed string.

def strip_prefix(string, prefix): (source)

Strip off prefix if it exists.

def unique_list(xs): (source)

Return a unique list from an iterable, preserving order.

def validate_version(python_version): (source)

Raise an exception if the python version is unsupported.

def version_from_string(version_string): (source)

Parse a version string like "3.7" into a tuple.

def _arg_names(f): (source)

Return the argument names of a function.

def _validate_python_version_upper_bound(): (source)

Undocumented

_VALIDATE_PYTHON_VERSION_UPPER_BOUND = (source)