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
TerminalController
A class that can be used to portably generate formatted output to a terminal.
Functions [hide private]
 
is_src_filename(filename) source code
call graph 
 
munge_script_name(filename) source code
string
plaintext_to_latex(str, nbsp=0, breakany=0)
Returns: A LaTeX string that encodes the given plaintext string.
source code
call graph 
 
run_subprocess(cmd, data=None)
Execute the command cmd in a subprocess.
source code
call graph 
    Python source types
 
is_module_file(path) source code
call graph 
 
is_package_dir(dirname)
Return true if the given directory is a valid package directory (i.e., it names a directory that contains a valid __init__ file, and its name is a valid identifier).
source code
call graph 
 
is_pyname(name) source code
 
py_src_filename(filename) source code
call graph 
    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.
source code
call graph 
str
wordwrap(str, indent=0, right=75, startindex=0, splitchars='')
Word-wrap the given string.
source code
call graph 
string
plaintext_to_html(s)
Returns: An HTML string that encodes the given plaintext string.
source code
call graph 
Variables [hide private]
  PY_SRC_EXTENSIONS = ['.py', '.pyw']
  PY_BIN_EXTENSIONS = ['.pyc', '.so', '.pyd']
Function Details [hide private]

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 
call graph 
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 
call graph 

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.