arelle.PythonUtil#

See COPYRIGHT.md for copyright information. Python version specific utilities

do not convert 3 to 2

Module Contents#

Classes#

attrdict

utility to simulate an object with named fields from a dict

OrderedDefaultDict

call with default factory and optional sorted initial entries e.g., OrderedDefaultDict(list, ((1,11),(2,22),…))

OrderedSet

Functions#

py3unquote

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.

pyTypeName

pyNamedObject

lcStr

strTruncate

normalizeSpace

flattenSequence

flattenToSet

Fraction

pyObjectSize

Recursively finds size of objects

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)#
class arelle.PythonUtil.OrderedSet(iterable=None)#

Bases: collections.abc.MutableSet

__len__()#
__contains__(key)#
add(key)#
update(other)#
discard(key)#
__iter__()#
__reversed__()#
pop(last=True)#
__repr__()#
__eq__(other)#
arelle.PythonUtil.Fraction(numerator, denominator=None)#
arelle.PythonUtil.pyObjectSize(obj, seen=None)#

Recursively finds size of objects