rattail.util
¶
Utilities
- rattail.util.capture_output(*args, **kwargs)[source]¶
Runs
command
and returns any output it produces.
- rattail.util.data_diffs(local_data, host_data, fields=None, fuzzy_fields=None, fuzz_factor=None)[source]¶
Find all (relevant) fields which differ between the host and local data values for a given record.
- rattail.util.get_class_hierarchy(klass, topfirst=True)[source]¶
DEPRECATED - use
wuttjamaican.util.get_class_hierarchy()
instead.
- rattail.util.get_package_name(name)[source]¶
Generic logic to derive a “package name” from the given name.
E.g. if
name
is “Poser Plus” this will return “poser_plus”
- rattail.util.get_pkg_version(name)[source]¶
Returns the version number for the given package name, per package metadata.
- rattail.util.get_studly_prefix(name)[source]¶
Generic logic to derive a “studly prefix” from the given name.
E.g. if
name
is “Poser Plus” this will return “PoserPlus”
- rattail.util.hours_as_decimal(hours, places=2)[source]¶
Convert the given
datetime.timedelta
object into a Decimal whose value is in terms of hours.
- rattail.util.import_module_path(module_path)[source]¶
Import an arbitrary Python module.
Warning
This function is deprecated; please use
importlib.import_module()
instead.- Parameters:
module_path¶ – String referencing a module by its “dotted path”.
- Returns:
The referenced module.
- rattail.util.import_reload(module)[source]¶
Reload a module.
Warning
This function is deprecated; please use
importlib.reload()
instead.- Parameters:
module¶ – An already-loaded module.
- Returns:
The module.
- rattail.util.load_entry_points(group, ignore_errors=False)[source]¶
Load a set of
setuptools
-style entry points.This is a compatibility wrapper around
wuttjamaican.util.load_entry_points()
. New code should use that instead; this will eventually be removed.
- rattail.util.load_object(spec)[source]¶
Load an arbitrary object from a module, according to a specifier.
This is a compatibility wrapper around
wuttjamaican.util.load_object()
. New code should use that instead; this will eventually be removed.
- rattail.util.make_uuid()[source]¶
Generate a universally-unique identifier.
- Returns:
A 32-character hex string.
- rattail.util.prettify(text)[source]¶
DEPRECATED - use
wuttjamaican.app.AppHandler.make_title()
instead.
- rattail.util.pretty_hours(hours=None, seconds=None)[source]¶
DEPRECATED - use
rattail.app.AppHandler.render_duration()
instead.
- rattail.util.pretty_quantity(value, empty_zero=False)[source]¶
Return a “pretty” version of the given value, as string. This is meant primarily for use with things like order quantities, so that e.g. 1.0000 => 1
- rattail.util.progress_loop(func, items, factory, *args, **kwargs)[source]¶
This will iterate over
items
and callfunc
for each. If a progressfactory
kwarg is provided, then a progress instance will be created and updated along the way.
- rattail.util.render_duration(delta=None, hours=None, seconds=None)[source]¶
Render a time duration for human eyes, e.g. “1:30” for 1.5 hours.
Note that you must specify one of:
delta
,hours
,seconds
.- Parameters:
- Returns:
Duration rendered as human-friendly string. Note that if all params are empty, this will return an empty string.