app.utils

Description

Collection of functions and classes which make common patterns shorter and easier.

Modules

app.utils.constants

app.utils.decorators

app.utils.file_storage

app.utils.libreoffice

app.utils.request_query_operator

Module for creating a Peewee filter query via dynamic way.

Functions

filter_by_keys(data, keys)

find_longest_word(word_list)

get_attr_from_module(module, attr)

Get attribute from a module.

get_request_file([field_name])

ignore_keys(data, exclude)

pos_to_char(pos)

to_readable(obj)

app.utils.filter_by_keys(data: dict, keys: list) dict
app.utils.find_longest_word(word_list: list) str
app.utils.get_attr_from_module(module: str, attr: str) any

Get attribute from a module.

Parameters
  • module (str) – Module absolute path.

  • attr (str) – Module’s attribute. It could be any kind of variable belongs to module.

Examples

>>> from app.utils import get_attr_from_module
>>> module_path = 'app.blueprints.base'
>>> module_attr = 'blueprint'
>>> get_attr_from_module(module_path, module_attr)
<flask.blueprints.Blueprint object at ...>
Raises
  • ImportError – Module doesn’t exist.

  • AttributeError – Attribute doesn’t exist in module.

app.utils.get_request_file(field_name: Optional[str] = None) dict
app.utils.ignore_keys(data: dict, exclude: list) dict
app.utils.pos_to_char(pos: int) str
app.utils.to_readable(obj: object) object