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¶
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.pyTypeName(object: Any) str¶
- arelle.PythonUtil.pyNamedObject(name: str, *args: Any, **kwargs: Any) Any¶
- arelle.PythonUtil.strTruncate(value: str, length: int) str¶
- arelle.PythonUtil.normalizeSpace(s: arelle.typing.OptionalString) arelle.typing.OptionalString¶
- arelle.PythonUtil.SEQUENCE_TYPES¶
()
- arelle.PythonUtil.flattenSequence(x: Any, sequence: list[Any] | None = None) list[Any]¶
- arelle.PythonUtil.flattenToSet(x: Any, _set: set[Any] | None = None) set[Any]¶
- class arelle.PythonUtil.attrdict(*args: Any, **kwargs: Any)¶
Bases:
dictutility 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: Any)¶
Bases:
collections.OrderedDictcall 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: Any) Any¶
- 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.pyObjectSize(obj: Any, seen: set[int] | None = None) int¶
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.