swimlane.utils package¶
Utility functions
-
swimlane.utils.get_recursive_subclasses(cls)[source]¶ Return list of all subclasses for a class, including subclasses of direct subclasses
-
swimlane.utils.import_submodules(package)[source]¶ Return list of imported module instances from beneath root_package
-
swimlane.utils.one_of_keyword_only(*valid_keywords)[source]¶ Decorator to help make one-and-only-one keyword-only argument functions more reusable
Notes
Decorated function should take 2 arguments, the first for the key, the second the value
Examples
@one_of_keyword_only('a', 'b', 'c') def func(key, value): if key == 'a': ... elif key == 'b': ... else: # key = 'c' ... ... func(a=1) func(b=2) func(c=3) try: func(d=4) except TypeError: ... try: func(a=1, b=2) except TypeError: ...
Parameters: *valid_keywords (str) – All allowed keyword argument names Raises: TypeError– On decorated call, if 0 or 2+ arguments are provided or kwargs contains a key not in valid_keywords
-
swimlane.utils.random_string(length, source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')[source]¶ Return random string of characters from source of specified length
Parameters: Returns: String of length number of characters composed of source characters
Return type: