common.utils module

common.utils.unaccent(text)[source]

Replace accented characters by unaccented ones.

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.

common.utils.jatsify_tags(text)[source]

Adds the jats: prefix to basic HTML tags. Nilpotent.

common.utils.get_current_domain()[source]
class common.utils.BaseMailUtil[source]

Bases: object

mail_sender = 'no-reply@scipost.org'
mail_sender_title = ''
classmethod load(_dict, request=None)[source]