Utils

inyoka.utils

Various application independent utilities.

copyright:
  1. 2007-2024 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

class inyoka.utils.classproperty(func, name=None)

A mix out of the built-in classmethod and property so that we can achieve a property that is not bound to an instance.

Example:

>>> class Foo(object):
...     bar = 'baz'
...
...     @classproperty
...     def bars(cls):
...         return [cls.bar]
...
>>> Foo.bars
['baz']
inyoka.utils.ctype(model)
inyoka.utils.get_request_context(request)
inyoka.utils.get_significant_digits(value, lower, upper)

Get the significant digits of value which are constrained by the (inclusive) lower and upper bounds.

If there are no significant digits which are definitely within the bounds, exactly one significant digit will be returned in the result.

>>> get_significant_digits(15, 15, 15)
15
>>> get_significant_digits(4777, 208, 6000)
5000
>>> get_significant_digits(9, 9, 100)
9
inyoka.utils.groupby(input, keyfunc)

References