Open source cms for mobile and desktop websites

nive.utils

nive.utils.utils.MakeListItems(items)

Turns a list into listItems used by form fields. Each item in the list is converted into a dict. e.g. ("a","b","c") or (("a","Name a"),("b","Name b"),("c","Name c"))

Parameters:items – list of items
Returns:listItems
nive.utils.utils.CutText(text, textlen, cutchars=' ;:, .\r\n', postfix=u' ...')

For text preview. cut the text at the last found char in cutchars.

nive.utils.utils.FormatBytesForDisplay(size)

Return the size of a file or directory formatted for display.

nive.utils.utils.TidyHtml(data, options=None)

clean up html by calling tidy

nive.utils.utils.ReplaceHTMLEntities(text, codepage=None)

Removes HTML or XML character references and entities from a text string.

nive.utils.utils.SortConfigurationList(values, sort, ascending=True)

Sorts the dictionary list values by attribute or key sort. This works for definitions.Conf() objects and simple dictionaries. Results can be ordered ascending or descending.

nive.utils.utils.ConvertToList(data, raiseExcp=False)
converts a string to list. the list items can be seperated by ”,” or “

nive.utils.utils.ConvertListToStr(values, sep=u', ', textMarker=u'', keepType=False)

converts a python list to string. . the list items are seperated by ”,”. list items are converted to string

nive.utils.utils.ConvertDictToStr(values, sep=u'\n')

converts a python dictionary to key list string. the list items are seperated by ”,”. list items are converted to string

::
key1: value1 key2: value2

result string

© 2013 Nive GmbH