sortinghat.utils package

Module contents

sortinghat.utils.generate_uuid(source, email=None, name=None, username=None)[source]

Generate a UUID related to identity data.

Based on the input data, the function will return the UUID associated to an identity. On this version, the UUID will be the SHA1 of source:email:name:username string.

This string is case insensitive, which means same values for the input parameters in upper or lower case will produce the same UUID.

The value of name will converted to its unaccent form which means same values with accent or unaccent chars (i.e ‘ö and o’) will generate the same UUID.

For instance, these combinations will produce the same UUID:

(‘scm’, ‘jsmith@example.com’, ‘John Smith’, ‘jsmith’), (‘scm’, ‘jsmith@example,com’, ‘Jöhn Smith’, ‘jsmith’), (‘scm’, ‘jsmith@example.com’, ‘John Smith’, ‘JSMITH’), (‘scm’, ‘jsmith@example.com’, ‘john Smith’, ‘jsmith’)

Parameters
  • source – data source

  • email – email of the identity

  • name – full name of the identity

  • username – user name used by the identity

Returns

a universal unique identifier for Sorting Hat

Raises

ValueError – when source is None or empty; each one of the parameters is None; or the parameters are empty.

sortinghat.utils.unaccent_string(unistr)[source]

Convert a Unicode string to its canonical form without accents.

This allows to convert Unicode strings which include accent characters to their unaccent canonical form. For instance, characters ‘Ê, ê, é, ë’ are considered the same character as ‘e’; characters ‘Ĉ, ć’ are the same as ‘c’.

Parameters

unistr – Unicode string to unaccent

Returns

Unicode string on its canonical form