podgen.util¶
This file contains helper functions for the feed generator module.
- copyright
2013, Lars Kiesow <lkiesow@uos.de> and 2016, Thorben Dahl <thorben@sjostrom.no>
- license
FreeBSD and LGPL, see license.* for more details.
-
podgen.util.
ensure_format
(val, allowed, required, allowed_values=None, defaults=None)[source]¶ Takes a dictionary or a list of dictionaries and check if all keys are in the set of allowed keys, if all required keys are present and if the values of a specific key are ok.
- Parameters
val – Dictionaries to check.
allowed – Set of allowed keys.
required – Set of required keys.
allowed_values – Dictionary with keys and sets of their allowed values.
defaults – Dictionary with default values.
- Returns
List of checked dictionaries.
-
podgen.util.
formatRFC2822
(d)[source]¶ Format a datetime according to RFC2822.
This implementation exists as a workaround to ensure that the locale setting does not interfere with the time format. For example, day names might get translated to your local language, which would break with the standard.
- Parameters
d (datetime.datetime) – Time and date you want to format according to RFC2822.
- Returns
The datetime formatted according to the RFC2822.
- Return type
-
podgen.util.
htmlencode
(s)[source]¶ Encode the given string so its content won’t be confused as HTML markup.
This function exists as a cross-version compatibility alias.
-
podgen.util.
listToHumanreadableStr
(l)[source]¶ Create a human-readable string out of the given iterable.
Example:
>>> from podgen.util import listToHumanreadableStr >>> listToHumanreadableStr([1, 2, 3]) 1, 2 and 3
The string
(empty)
is returned if the list is empty – it is assumed that you check whether the list is empty yourself.