module documentation

Undocumented

Class StreamingBuffer Undocumented
Class Truncator An object used to truncate text, either by characters or words.
Function camel_case_to_spaces Split CamelCase and convert to lowercase. Strip surrounding whitespace.
Function capfirst Capitalize the first letter of a string.
Function compress_sequence Undocumented
Function compress_string Undocumented
Function get_text_list >>> get_text_list(['a', 'b', 'c', 'd']) 'a, b, c or d' >>> get_text_list(['a', 'b', 'c'], 'and') 'a, b and c' >>> get_text_list(['a', 'b'], 'and') 'a and b' >>> get_text_list(['a']) 'a' >>> get_text_list([]) ''...
Function get_valid_filename Return the given string converted to a string that can be used for a clean filename. Remove leading and trailing spaces; convert other spaces to underscores; and remove anything that is not an alphanumeric, dash, underscore, or dot...
Function normalize_newlines Normalize CRLF and CR newlines to just LF.
Function phone2numeric Convert a phone number with letters into its numeric equivalent.
Function slugify Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.
Function smart_split Generator that splits a string by spaces, leaving quoted phrases together. Supports both single and double quotes, and supports escaping quotes with backslashes. In the output, strings will keep their initial and trailing quote marks and escaped quotes will remain escaped (the results can then be further processed with unescape_string_literal()).
Function unescape_string_literal Convert quoted string literals to unquoted strings with escaped quotes and backslashes unquoted::
Function wrap A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines.
Variable format_lazy Undocumented
Variable re_camel_case Undocumented
Variable re_chars Undocumented
Variable re_newlines Undocumented
Variable re_tag Undocumented
Variable re_words Undocumented
Variable smart_split_re Undocumented
Function _format_lazy Apply str.format() on 'format_string' where format_string, args, and/or kwargs might be lazy.
def camel_case_to_spaces(value): (source)

Split CamelCase and convert to lowercase. Strip surrounding whitespace.

Capitalize the first letter of a string.

def compress_sequence(sequence): (source)

Undocumented

def compress_string(s): (source)

Undocumented

@keep_lazy_text
def get_text_list(list_, last_word=gettext_lazy('or')): (source)

>>> get_text_list(['a', 'b', 'c', 'd']) 'a, b, c or d' >>> get_text_list(['a', 'b', 'c'], 'and') 'a, b and c' >>> get_text_list(['a', 'b'], 'and') 'a and b' >>> get_text_list(['a']) 'a' >>> get_text_list([]) ''

@keep_lazy_text
def get_valid_filename(name): (source)

Return the given string converted to a string that can be used for a clean filename. Remove leading and trailing spaces; convert other spaces to underscores; and remove anything that is not an alphanumeric, dash, underscore, or dot. >>> get_valid_filename("john's portrait in 2004.jpg") 'johns_portrait_in_2004.jpg'

@keep_lazy_text
def normalize_newlines(text): (source)

Normalize CRLF and CR newlines to just LF.

@keep_lazy_text
def phone2numeric(phone): (source)

Convert a phone number with letters into its numeric equivalent.

@keep_lazy_text
def slugify(value, allow_unicode=False): (source)

Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.

def smart_split(text): (source)

Generator that splits a string by spaces, leaving quoted phrases together. Supports both single and double quotes, and supports escaping quotes with backslashes. In the output, strings will keep their initial and trailing quote marks and escaped quotes will remain escaped (the results can then be further processed with unescape_string_literal()). >>> list(smart_split(r'This is "a person\'s" test.')) ['This', 'is', '"a person\\\'s"', 'test.'] >>> list(smart_split(r"Another 'person\'s' test.")) ['Another', "'person\\'s'", 'test.'] >>> list(smart_split(r'A "\"funky\" style" test.')) ['A', '"\\"funky\\" style"', 'test.']

@keep_lazy_text
def unescape_string_literal(s): (source)

Convert quoted string literals to unquoted strings with escaped quotes and backslashes unquoted:: >>> unescape_string_literal('"abc"') 'abc' >>> unescape_string_literal("'abc'") 'abc' >>> unescape_string_literal('"a \"bc\""') 'a "bc"' >>> unescape_string_literal("'\'ab\' c'") "'ab' c"

@keep_lazy_text
def wrap(text, width): (source)

A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines. Preserve all white space except added line breaks consume the space on which they break the line. Don't wrap long words, thus the output text may have lines longer than ``width``.

format_lazy = (source)

Undocumented

re_camel_case = (source)

Undocumented

re_chars = (source)

Undocumented

re_newlines = (source)

Undocumented

Undocumented

re_words = (source)

Undocumented

smart_split_re = (source)

Undocumented

def _format_lazy(format_string, *args, **kwargs): (source)

Apply str.format() on 'format_string' where format_string, args, and/or kwargs might be lazy.