arelle.PythonUtil
¶
See COPYRIGHT.md for copyright information. Python version specific utilities
do not convert 3 to 2
Module Contents¶
Classes¶
utility to simulate an object with named fields from a dict |
|
call with default factory and optional sorted initial entries e.g., OrderedDefaultDict(list, ((1,11),(2,22),…)) |
|
OrderedSet implementation copied from Python recipe: https://code.activestate.com/recipes/576694/ |
|
Like frozenset vs set, this is the immutable counterpart to OrderedSet. Maintains insertion order and provides set-like operations without mutation. |
|
Functions¶
Replace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. By default, percent-encoded sequences are decoded with UTF-8, and invalid sequences are replaced by a placeholder character. |
|
Recursively finds size of objects |
|
Tries to return the results of the provided command. Returns stdout or None if the command exists with a non-zero code. |
|
Implements legacy behavior of os.path.isabs() prior to Python 3.13 where True was returned for paths beginning with single slashes on Windows. |
Data¶
API¶
- arelle.PythonUtil.STR_NUM_TYPES¶
()
- arelle.PythonUtil.py3unquote(string, encoding='utf-8', errors='replace')¶
Replace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. By default, percent-encoded sequences are decoded with UTF-8, and invalid sequences are replaced by a placeholder character.
unquote(‘abc%20def’) -> ‘abc def’.
- arelle.PythonUtil.pyTypeName(object)¶
- arelle.PythonUtil.pyNamedObject(name, *args, **kwargs)¶
- arelle.PythonUtil.lcStr(value)¶
- arelle.PythonUtil.strTruncate(value, length) str ¶
- arelle.PythonUtil.normalizeSpace(s: arelle.typing.OptionalString) arelle.typing.OptionalString ¶
- arelle.PythonUtil.SEQUENCE_TYPES¶
()
- arelle.PythonUtil.flattenSequence(x, sequence=None) list[Any] ¶
- arelle.PythonUtil.flattenToSet(x, _set=None)¶
- class arelle.PythonUtil.attrdict(*args, **kwargs)¶
Bases:
dict
utility to simulate an object with named fields from a dict
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class arelle.PythonUtil.OrderedDefaultDict(*args)¶
Bases:
collections.OrderedDict
call with default factory and optional sorted initial entries e.g., OrderedDefaultDict(list, ((1,11),(2,22),…))
Initialization
Initialize self. See help(type(self)) for accurate signature.
- __missing__(key)¶
- arelle.PythonUtil.T¶
‘TypeVar(…)’
- class arelle.PythonUtil.OrderedSet(iterable: collections.abc.Iterable[arelle.PythonUtil.T] | None = None)¶
Bases:
collections.abc.MutableSet
[arelle.PythonUtil.T
]OrderedSet implementation copied from Python recipe: https://code.activestate.com/recipes/576694/
Initialization
- __getitem__(index: int) arelle.PythonUtil.T ¶
- __len__() int ¶
- __contains__(key: object) bool ¶
- add(key: arelle.PythonUtil.T) None ¶
- update(other: collections.abc.Iterable[arelle.PythonUtil.T]) None ¶
- discard(key: arelle.PythonUtil.T) None ¶
- __iter__() collections.abc.Iterator[arelle.PythonUtil.T] ¶
- __reversed__() collections.abc.Iterator[arelle.PythonUtil.T] ¶
- pop(last: bool = True) arelle.PythonUtil.T ¶
- __repr__() str ¶
- __eq__(other: object) bool ¶
- class arelle.PythonUtil.FrozenOrderedSet(iterable: collections.abc.Iterable[arelle.PythonUtil.T] | None = None)¶
Bases:
collections.abc.Set
[arelle.PythonUtil.T
]Like frozenset vs set, this is the immutable counterpart to OrderedSet. Maintains insertion order and provides set-like operations without mutation.
Initialization
- __getitem__(index: int) arelle.PythonUtil.T ¶
- __len__() int ¶
- __contains__(key: object) bool ¶
- __iter__() collections.abc.Iterator[arelle.PythonUtil.T] ¶
- __reversed__() collections.abc.Iterator[arelle.PythonUtil.T] ¶
- __repr__() str ¶
- __eq__(other: object) bool ¶
- __hash__() int ¶
- arelle.PythonUtil.KT¶
‘TypeVar(…)’
- arelle.PythonUtil.VT¶
‘TypeVar(…)’
- class arelle.PythonUtil.FrozenDict(data: collections.abc.Mapping[arelle.PythonUtil.KT, arelle.PythonUtil.VT] | None = None)¶
Bases:
typing.Generic
[arelle.PythonUtil.KT
,arelle.PythonUtil.VT
],collections.abc.Mapping
[arelle.PythonUtil.KT
,arelle.PythonUtil.VT
]- __getitem__(key: arelle.PythonUtil.KT) arelle.PythonUtil.VT ¶
- __iter__() collections.abc.Iterator[arelle.PythonUtil.KT] ¶
- __len__() int ¶
- __repr__() str ¶
- __eq__(other: Any) bool ¶
- __hash__() int ¶
- arelle.PythonUtil.Fraction(numerator, denominator=None)¶
- arelle.PythonUtil.pyObjectSize(obj, seen=None)¶
Recursively finds size of objects
- arelle.PythonUtil.tryRunCommand(*args: str) str | None ¶
Tries to return the results of the provided command. Returns stdout or None if the command exists with a non-zero code.
- arelle.PythonUtil.isLegacyAbs(path: str) bool ¶
Implements legacy behavior of os.path.isabs() prior to Python 3.13 where True was returned for paths beginning with single slashes on Windows.