wfexs_backend.utils.misc#

Module Contents#

Classes#

Functions#

translate_glob_args

datetimeFromISOFormat

Construct a datetime from the output of datetime.isoformat().

_parse_isoformat_date

_parse_isoformat_time

_parse_hh_mm_ss_ff

load_with_datetime

Load with dates

jsonFilterDecodeFromStream

Decode JSON content from a stream, translating ISO8601 dates to strings

config_validate

iter_namespace

get_opener_with_auth

Taken from https://stackoverflow.com/a/44239906

lazy_import

Inspired in https://docs.python.org/3/library/importlib.html#implementing-lazy-imports

is_uri

Inspired in https://stackoverflow.com/a/38020041

get_maximum_file_descriptors

Get the maximum number of open file descriptors for this process.

Data#

API#

wfexs_backend.utils.misc.translate_glob_args(args: Iterator[str] | Sequence[str]) Sequence[Pattern[str]]#
class wfexs_backend.utils.misc.DatetimeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#

Bases: json.JSONEncoder

default(obj: Any) Any#
wfexs_backend.utils.misc.datetimeFromISOFormat(date_string: str) datetime.datetime#

Construct a datetime from the output of datetime.isoformat().

wfexs_backend.utils.misc._parse_isoformat_date(dtstr: str) Tuple[int, int, int]#
wfexs_backend.utils.misc._parse_isoformat_time(tstr: str) Tuple[Tuple[int, int, int, int], datetime.timezone | None]#
wfexs_backend.utils.misc._parse_hh_mm_ss_ff(tstr: str) Tuple[int, int, int, int]#
wfexs_backend.utils.misc.load_with_datetime(pairs: Sequence[Tuple[str, Any]], tz: datetime.tzinfo | None = None) Mapping[str, Any]#

Load with dates

wfexs_backend.utils.misc.jsonFilterDecodeFromStream(stream: TextIO, tz: datetime.tzinfo | None = None) Any#

Decode JSON content from a stream, translating ISO8601 dates to strings

exception wfexs_backend.utils.misc.ConfigValidationException#

Bases: wfexs_backend.common.AbstractWfExSException

wfexs_backend.utils.misc.SCHEMAS_REL_DIR = 'schemas'#
wfexs_backend.utils.misc.config_validate(configToValidate: Mapping[str, Any] | Sequence[Mapping[str, Any]], relSchemaFile: wfexs_backend.common.RelPath) Sequence[ValidationError]#
wfexs_backend.utils.misc.iter_namespace(ns_pkg: types.ModuleType) Iterator[pkgutil.ModuleInfo]#
wfexs_backend.utils.misc.get_opener_with_auth(top_level_url: str, username: str, password: str) urllib.request.OpenerDirector#

Taken from https://stackoverflow.com/a/44239906

wfexs_backend.utils.misc.lazy_import(name: str) types.ModuleType#

Inspired in https://docs.python.org/3/library/importlib.html#implementing-lazy-imports

wfexs_backend.utils.misc.is_uri(the_uri: str) bool#

Inspired in https://stackoverflow.com/a/38020041

wfexs_backend.utils.misc.MAXFD = 2048#
wfexs_backend.utils.misc.get_maximum_file_descriptors() int#

Get the maximum number of open file descriptors for this process.

Returns:

The number (integer) to use as the maximum number of open files for this process.

The maximum is the process hard resource limit of maximum number of open file descriptors. If the limit is “infinity”, a default value of MAXFD is returned.