flexget.utils.tools module#
Contains miscellaneous helpers.
- exception flexget.utils.tools.MergeException(value)[source]#
Bases:
Exception- Parameters:
value (str)
- class flexget.utils.tools.BufferQueue(maxsize=0)[source]#
Bases:
QueueUsed in place of a file-like object to capture text and access it safely from another thread.
- class flexget.utils.tools.ReList(*args, **kwargs)[source]#
Bases:
listA list that stores regexps.
You can add compiled or uncompiled regexps to the list. It will always return the compiled version. It will compile the text regexps on demand when first accessed.
- flags = 2#
- class flexget.utils.tools.TimedDict(cache_time='5 minutes')[source]#
Bases:
MutableMappingActs like a normal dict, but keys will only remain in the dictionary for a specified time span.
- Parameters:
cache_time (timedelta | str)
- classmethod clear_all()[source]#
Clear all instantiated TimedDicts.
Used by tests to make sure artifacts don’t leak between tests.
- _abc_impl = <_abc._abc_data object>#
- class flexget.utils.tools.TitleYear(title, year)[source]#
Bases:
NamedTuple- classmethod _make(iterable)#
Make a new TitleYear object from a sequence or iterable
- _asdict()#
Return a new dict which maps field names to their values.
- _replace(**kwds)#
Return a new TitleYear object replacing specified fields with new values
- _field_defaults = {}#
- _fields = ('title', 'year')#
- flexget.utils.tools.chunked(seq, limit=900)[source]#
Divide our expired lists into sizes sqlite can handle in a query. (<1000).
- Parameters:
seq (Sequence)
limit (int)
- Return type:
Iterator[Sequence]
- flexget.utils.tools.decode_html(value)[source]#
Return Html decoded string.
- Parameters:
value (string) – String to be html-decoded
- Return type:
- flexget.utils.tools.encode_html(unicode_data, encoding='ascii')[source]#
Encode unicode_data for use as XML or HTML, with characters outside of the encoding converted to XML numeric character references.
- flexget.utils.tools.format_filesize(num_bytes, si=False, unit=None)[source]#
Return given bytes as prettified string.
- flexget.utils.tools.get_config_as_array(config, key)[source]#
Return configuration key as array, even if given as a single string.
- flexget.utils.tools.get_latest_flexget_version_number()[source]#
Return latest Flexget version from https://pypi.python.org/pypi/FlexGet/json.
- Return type:
str | None
- flexget.utils.tools.merge_dict_from_to(d1, d2)[source]#
Merge dictionary d1 into dictionary d2. d1 will remain in original form.
- flexget.utils.tools.multiply_timedelta(interval, number)[source]#
timedelta cannot normally be multiplied by floating points. This does that.
- flexget.utils.tools.parse_episode_identifier(ep_id, identify_season=False)[source]#
Parse series episode identifier, raise ValueError if it fails.
- flexget.utils.tools.parse_filesize(text_size, si=True, match_re=None)[source]#
Parse a data size and returns its value in bytes.
- Parameters:
text_size (string) – string containing the data size to parse i.e. “5 GB”
si (bool) – If True, possibly ambiguous units like KB, MB, GB will be assumed to be base 10 units, rather than base 2. i.e. if si then 1 KB = 1000 B else 1 KB = 1024 B
match_re (str | Pattern[str] | None) – A custom regex can be defined to match the size. The first capture group should match the number, and the second should match the unit.
- Returns:
an int with the data size in bytes
- Return type:
- flexget.utils.tools.parse_timedelta(value)[source]#
Parse a string like ‘5 days’ into a timedelta object. Also allows timedeltas to pass through.