Package translate :: Package misc :: Module quote

[hide private]
[frames] | no frames]

# Module quote

source code

string processing utilities for extracting strings with various kinds of delimiters

Functions | [hide private]

find_all(searchin, substr) returns a list of locations where substr occurs in searchin locations are not allowed to overlap | source code

extract(source, startdelim, enddelim, escape=None, startinstring=False, allowreentry=True) Extracts a doublequote-delimited string from a string, allowing for backslash-escaping returns tuple of (quoted string with quotes, still in string at end) | source code

extractfromlines(lines, startdelim, enddelim, escape) Calls extract over multiple lines, remembering whether in the string or not | source code

extractstr(source) Extracts a doublequote-delimited string from a string, allowing for backslash-escaping | source code

extractcomment(lines) Extracts <!-- > XML comments from lines | source code

extractwithoutquotes(source, startdelim, enddelim, escape=None, startinstring=False, includeescapes=True, allowreentry=True) Extracts a doublequote-delimited string from a string, allowing for backslash-escaping includeescapes can also be a function that takes the whole escaped string and returns the replaced version | source code

escapequotes(source, escapeescapes=0) Returns the same string, with double quotes escaped with backslash | source code

escapesinglequotes(source) Returns the same string, with single quotes doubled | source code

htmlentityencode(source) encodes source using HTML entities e.g. | source code

htmlentitydecode(source) decodes source using HTML entities e.g. | source code

javapropertiesencode(source) encodes source in the escaped-unicode encoding used by Java .properties files | source code

mozillapropertiesencode(source) encodes source in the escaped-unicode encoding used by Mozilla .properties files | source code

escapecontrols(source) escape control characters in the given string | source code

mozillapropertiesdecode(source) decodes source from the escaped-unicode encoding used by mozilla .properties files | source code

quotestr(source, escapeescapes=0) Returns a doublequote-delimited quoted string, escaping double quotes with backslash | source code

singlequotestr(source) Returns a doublequote-delimited quoted string, escaping single quotes with themselves | source code

eitherquotestr(source) Returns a singlequote- or doublequote-delimited string, depending on what quotes it contains | source code

findend(string, substring) | source code

rstripeol(string) | source code

stripcomment(comment, startstring=`'``<!--``'`, endstring=`'``-->``'`) | source code

unstripcomment(comment, startstring=`'``<!--` `'`, endstring=`'``-->\n``'`) | source code

encodewithdict(unencoded, encodedict) encodes certain characters in the string using an encode dictionary | source code

makeutf8(d) convert numbers to utf8 codes in the values of a dictionary | source code

testcase() | source code

Variables | [hide private]

| propertyescapes = ``{``'``"``'``:` `'``"``'``,` `'``\'``'``:` `'``\'``'``,` `'``\\``'``:` `'``\\``'``,` `'``a``'``:` `'``\x0``...``
| controlchars = ``{``'``\x08``'``:` `'``\\b``'``,` `'``\t``'``:` `'``\\t``'``,` `'``\n``'``:` `'``\\n``'``,` `'``\x0b``...``

Function Details | [hide private]

### htmlentityencode(source)

source code

encodes source using HTML entities e.g. © -> &copy;

### htmlentitydecode(source)

source code

decodes source using HTML entities e.g. &copy; -> ©

Variables Details | [hide private]

### propertyescapes

Value:

      {'"': '"',
       '\'': '\'',
       '\\': '\\',
       'a': '\x07',
       'b': '\x08',
       'f': '\x0c',
       'n': '''
      ''',
      ...

### controlchars

Value:

      {'\x08': '\\b',
       '\t': '\\t',
       '''
      ''': '\\n',
       '\x0b': '\\v',
       '\x0c': '\\f'}