privex.helpers.decorators.FormatOpt¶
-
class
privex.helpers.decorators.
FormatOpt
[source]¶ This enum represents various options available for
r_cache()
‘sformat_opt
parameter.To avoid bloating the PyDoc for
r_cache
too much, descriptions for each formatting option is available as a short PyDoc comment under each enum option.Usage:
>>> @r_cache('mykey', format_args=[0, 'x'], format_opt=FormatOpt.POS_AUTO)
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
Attributes
Only use kwargs for formatting the cache key - requires named format placeholders, i.e.
Use both *args and **kwargs to format the cache_key (assuming mixed placeholders e.g.``mykey:{}:{y}``.
First attempt to format using *args whitelisted in
format_args
, if that causes a KeyError/IndexError, then pass kwarg values in the order they’re listed informat_args
(only includes kwarg names listed informat_args
)Only use positional args for formatting the cache key, kwargs will be ignored completely.
-
KWARG_ONLY
= 'kwarg'¶ Only use kwargs for formatting the cache key - requires named format placeholders, i.e.
mykey:{x}
-
MIX
= 'mix'¶ Use both *args and **kwargs to format the cache_key (assuming mixed placeholders e.g.
mykey:{}:{y}
-
POS_AUTO
= 'force_pos'¶ First attempt to format using *args whitelisted in
format_args
, if that causes a KeyError/IndexError, then pass kwarg values in the order they’re listed informat_args
(only includes kwarg names listed informat_args
)# def func(x, y) func(‘a’, ‘b’) # assuming 0 and 1 are in format_args, then it would use .format(‘a’, ‘b’) func(y=’b’, x=’a’) # assuming format_args =
['x','y']
, then it would use .format(‘a’, ‘b’)
-
POS_ONLY
= 'pos_only'¶ Only use positional args for formatting the cache key, kwargs will be ignored completely.
-