class keg.utils.ClassProperty(fget, *arg, **kw)[source]

A decorator that behaves like @property except that operates on classes rather than instances.

class keg.utils.HybridMethod(func, cm_func=None)[source]

A decorator which allows definition of a Python object method with both instance-level and class-level behavior:

Class Bar:
    def foo(self, rule, **options):
        # this is used in an instance context

    def foo(cls, rule, **options):
        # this is used in class context

Provide a modifying decorator that is used as a classmethod decorator.

keg.utils.app_environ_get(app_import_name, key, default=None)[source]
keg.utils.ensure_dirs(newdir, mode=<class 'keg.utils.NotGiven'>)[source]

A “safe” verision of Path.makedir(…, parents=True) that will only create the directory if it doesn’t already exist. We also manually create parents so that mode is set correctly. Python docs say that mode is ignored when using Path.mkdir(…, parents=True)


Takes an iterable of file paths reprenting possible python modules and will return an iterable of tuples with the file path along with the contents of that file if the file exists.

If the file does not exist or cannot be accessed, the third term of the tuple stores the exception.

keg.utils.visit_modules(dotted_paths, base_path=None)[source]