useful_inkleby.decorators package


useful_inkleby.decorators.base module

Created on Jul 25, 2016

@author: Alex

class useful_inkleby.decorators.base.DecortorMeta[source]

Bases: type

class useful_inkleby.decorators.base.GenericDecorator(*args, **kwargs)[source]

Bases: object

tidies up shell game of decorators. arguments passed to the decorator at creation end up as self.args and self.kwargs. kwargs are also added to self. if args_map is populated - will also add those to self

args_map = (“foo”,)

populates with args[0]

if there is no args_map can be used bare (without initalisation)

default_kwargs sets the default value of any kwargs that might be passed in (also added to self)

override self.gateway if it’s a choice between using this function and a different one

overide self.arg_decorator to adjust arguments being passed in

expects self, function, then delivers any args and kwargs passed to the function

classmethod allow_bare()[source]

can this decorator be used without initialisation?

only if no args_map - or all values in args_map are
already provided by default_kwargs
arg_decorator(function, *args, **kwargs)[source]

” accesses properties passed to decorated object through arguments

args_map = []
default_kwargs = {}

override if this is a “return this or something else” decorator

Use super or call self.raw_decorator() to proceed


passed self and the created object return final object when done


passed self and the result of the function return final object when done


accesses properties passed to decorator through self reference

Module contents