wfexs_backend.utils.misc#
Module Contents#
Classes#
Functions#
Construct a datetime from the output of datetime.isoformat(). |
|
Load with dates |
|
Decode JSON content from a stream, translating ISO8601 dates to strings |
|
Create an opener object from a list of handlers. |
|
Taken from https://stackoverflow.com/a/44239906 |
|
Inspired in https://docs.python.org/3/library/importlib.html#implementing-lazy-imports |
|
Inspired in https://stackoverflow.com/a/38020041 |
|
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
- 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_time(tstr: str) Tuple[Tuple[int, int, int, int], datetime.timezone | None]#
- 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#
- 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.build_http_opener(*handlers: urllib.request.BaseHandler | Type[urllib.request.BaseHandler], implicit_redirect: bool = True) urllib.request.OpenerDirector#
Create an opener object from a list of handlers.
The opener will use several default handlers only related to HTTP, and when applicable HTTPS.
If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used.
- wfexs_backend.utils.misc.get_opener_with_auth(top_level_url: str, username: str, password: str, implicit_redirect: bool = True) 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
MAXFDis returned.