Other utils

xoutil.web.slugify(s, entities=True, decimal=True, hexadecimal=True)[source]

Normalizes string, converts to lower-case, removes non-alpha characters, and converts spaces to hyphens.

Parts from http://www.djangosnippets.org/snippets/369/

>>> slugify("Manuel Vázquez Acosta")    
'manuel-vazquez-acosta'

If s and entities is True (the default) all HTML entities are replaced by its equivalent character before normalization:

>>> slugify("Manuel Vázquez Acosta")   
'manuel-vazquez-acosta'

If entities is False, then no HTML-entities substitution is made:

>>> value = "Manuel Vázquez Acosta"
>>> slugify(value, entities=False)  
'manuel-v-aacute-zquez-acosta'

If decimal is True, then all entities of the form &#nnnn where nnnn is a decimal number deemed as a unicode codepoint, are replaced by the corresponding unicode character:

>>> slugify('Manuel Vázquez Acosta')  
'manuel-vazquez-acosta'

>>> value = 'Manuel Vázquez Acosta'
>>> slugify(value, decimal=False)  
'manuel-v-225-zquez-acosta'

If hexadecimal is True, then all entities of the form &#nnnn where nnnn is a hexdecimal number deemed as a unicode codepoint, are replaced by the corresponding unicode character:

>>> slugify('Manuel Vázquez Acosta')  
'manuel-vazquez-acosta'

>>> slugify('Manuel Vázquez Acosta', hexadecimal=False)  
'manuel-v-x00e1-zquez-acosta'
xoutil.uuid.uuid(*args, **kw)[source]

Return a “Global Unique ID” as a string.

Parameters:random – If True, a random uuid is generated (does not use host id).