Package epydoc :: Module util
[hide private]
[frames] | no frames]

Module util
source code

Miscellaneous utility functions that are used by multiple modules.

Classes [hide private]
RunSubprocessError  

Functions [hide private]
  is_src_filename(filename)
  munge_script_name(filename)
string plaintext_to_latex(str, nbsp=0, breakany=0)
  run_subprocess(cmd, data=None)
Execute the command cmd in a subprocess.
    Python source types
  is_module_file(path)
  is_package_dir(dirname)
Return true if the given directory is a valid package directory (i.e., it names a directory that contsains a valid __init__ file, and its name is a valid identifier).
  is_pyname(name)
  py_src_filename(filename)
    Text processing
  decode_with_backslashreplace(s)
Convert the given 8-bit string into unicode, treating any character c such that ord(c)<128 as an ascii character, and converting any c such that ord(c)>128 into a backslashed escape sequence.
str wordwrap(str, indent=0, right=75, startindex=0, splitchars='')
Word-wrap the given string.
string plaintext_to_html(s)

Variables [hide private]
PY_SRC_EXTENSIONS  
PY_BIN_EXTENSIONS  

Function Details [hide private]

is_module_file(path)

source code 
call graph 

is_src_filename(filename)

source code 
call graph 

is_package_dir(dirname)

source code 
call graph 
Return true if the given directory is a valid package directory (i.e., it names a directory that contsains a valid __init__ file, and its name is a valid identifier).

is_pyname(name)

source code 

py_src_filename(filename)

source code 
call graph 

munge_script_name(filename)

source code 

decode_with_backslashreplace(s)

source code 
call graph 
Convert the given 8-bit string into unicode, treating any character c such that ord(c)<128 as an ascii character, and converting any c such that ord(c)>128 into a backslashed escape sequence.
>>> decode_with_backslashreplace('abc\xff\xe8')
u'abc\\xff\\xe8'

wordwrap(str, indent=0, right=75, startindex=0, splitchars='')

source code 
call graph 
Word-wrap the given string. I.e., add newlines to the string such that any lines that are longer than right are broken into shorter lines (at the first whitespace sequence that occurs before index right). If the given string contains newlines, they will not be removed. Any lines that begin with whitespace will not be wordwrapped.
Parameters:
  • indent (int) - If specified, then indent each line by this number of spaces.
  • right (int) - The right margin for word wrapping. Lines that are longer than right will be broken at the first whitespace sequence before the right margin.
  • startindex (int) - If specified, then assume that the first line is already preceeded by startindex characters.
  • splitchars - A list of non-whitespace characters which can be used to split a line. (E.g., use '/\' to allow path names to be split over multiple lines.)
Returns: str

plaintext_to_html(s)

source code 
call graph 
Returns: string
An HTML string that encodes the given plaintext string. In particular, special characters (such as '<' and '&') are escaped.

plaintext_to_latex(str, nbsp=0, breakany=0)

source code 
Parameters:
  • breakany - Insert hyphenation marks, so that LaTeX can break the resulting string at any point. This is useful for small boxes (e.g., the type box in the variable list table).
  • nbsp - Replace every space with a non-breaking space ('~').
Returns: string
A LaTeX string that encodes the given plaintext string. In particular, special characters (such as '$' and '_') are escaped, and tabs are expanded.

run_subprocess(cmd, data=None)

source code 
Execute the command cmd in a subprocess.
Parameters:
  • cmd - The command to execute, specified as a list of string.
  • data - A string containing data to send to the subprocess.
Returns:
A tuple (out, err).
Raises:
  • OSError - If there is any problem executing the command, or if its exitval is not 0.

Variables Details [hide private]

PY_SRC_EXTENSIONS

Value:
['.py', '.pyw']                                                        
      

PY_BIN_EXTENSIONS

Value:
['.pyc', '.so', '.pyd']