Package pyffi :: Package utils
[hide private]
[frames] | no frames]

Package utils

source code

This module bundles various general purpose utilities: - hexdumping - parsing all files in a directory tree - 3D related tasks (see TriStrip.py, MathUtils.py, QuickHull.py, and Inertia.py)
Submodules [hide private]

Functions [hide private]
 
walk(top, topdown=True, onerror=None, re_filename=None)
A variant of os.walk() which also works if top is a file instead of a directory, filters files by name, and returns full path.
source code
 
hex_dump(f, num_lines=8)
A function for hexdumping.
source code
 
unique_map(hash_generator)
Return a map and inverse map to indentify unique values based on hash, which is useful for removing duplicate data.
source code
Variables [hide private]
  chartable = '................................ !"#$%&\'()*+,-./...
  __package__ = 'pyffi.utils'
Function Details [hide private]

walk(top, topdown=True, onerror=None, re_filename=None)

source code 
A variant of os.walk() which also works if top is a file instead of a directory, filters files by name, and returns full path. File names are returned in alphabetical order.
Parameters:
  • top (str) - The top directory or file.
  • topdown (bool) - Whether to list directories first or not.
  • onerror (function) - Which function to call when an error occurs.
  • re_filename (compiled regular expression (see re module)) - Regular expression to match file names.

unique_map(hash_generator)

source code 

Return a map and inverse map to indentify unique values based on hash, which is useful for removing duplicate data. If the hash generator yields None then the value is mapped to None (useful for discarding data).

>>> unique_map([])
([], [])
>>> unique_map([3,2,6,None,1])
([0, 1, 2, None, 3], [0, 1, 2, 4])
>>> unique_map([3,1,6,1])
([0, 1, 2, 1], [0, 1, 2])
>>> unique_map([3,1,6,1,2,2,9,3,2])
([0, 1, 2, 1, 3, 3, 4, 0, 3], [0, 1, 2, 4, 6])

Variables Details [hide private]

chartable

Value:
'................................ !"#$%&\'()*+,-./0123456789:;<=>?@ABC\
DEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~..........\
......................................................................\
.................................................'