craftr.utils
¶
Various common utilities used by Craftr and its extension modules.
Transform Functions¶
Recordclass¶
-
class
craftr.utils.
recordclass_base
(*args, **kwargs)[source]¶ Base class that provides a namedtuple like interface based on the
__slots__
parameter.class MyRecord(recordclass_base): __slots__ = 'foo bar ham'.split() data = MyRecord('a foo', 42, ham="spam")
-
craftr.utils.
recordclass
(__name, __fields, **defaults)[source]¶ Creates a new class that can represent a record with the specified fields. This is equal to a mutable namedtuple. The returned class also supports keyword arguments in its constructor.
Parameters: - __name – The name of the recordclass.
- __fields – A string or list of field names.
- defaults – Default values for fields. The defaults may list field names that haven’t been listed in fields.
Environment Variables¶
craftr.utils.regex
Module¶
Regex utility functions.
-
craftr.utils.regex.
search_get_groups
(pattern, subject, mode=0)[source]¶ Performs
re.search()
and returns a list of the captured groups, including the complete matched string as the first group. If the regex search was unsuccessful, a list with that many items containing None is returned.