common.utils module¶
-
common.utils.
alternative_spellings
(text)[source]¶ From a string, return a list with alternative spellings.
Text searches can be run with accents stripped away. This is however insufficient if character sequences are interpreted as accented characters.
This method provides a set of alternative spellings based on beyond-ignoring-accents substitutions.
The substitutions which are handled are:
ae to/from ä (also capitalized)
oe to/from ö (also capitalized)
ue to/from ü (also capitalized)
Limitations:
each substitution in the substitutions dictionary is applied to the whole of the text string (so this does not cover cases where a text string has inconsistent spelling mixing the different alternatives)
-
common.utils.
Q_with_alternative_spellings
(**lookup_dict)[source]¶ Dress an existing Q query with alternative spellings.
Keyword parameters: - lookup_dict: a single-entry dict giving the query
Conditions: - lookup_dict contains a single entry - the to-be-match item must be of string type
-
common.utils.
hslColorWheel
(N=10, index=0, saturation=50, lightness=50)[source]¶ Distributes colors into N values around a color wheel, according to hue-saturation-lightness (HSL).
index takes values from 0 to N-1.
-
common.utils.
workdays_between
(date_from, date_until)[source]¶ Return number of complete workdays.
Given two datetime parameters, this function returns the number of complete workdays (defined as weekdays) separating them.
Adds the jats: prefix to basic HTML tags. Nilpotent.