Common utilities.
This module provides common utilities helpful in writing scripts, used
in our example scripts. Functions to parse the command-line with
commonly used options and a base class for implementing an interactive
shell-like interface.
bool
|
floatEqual(f1,
f2,
epsilon=1e-6)
Returns:
True if the two given floats are equal within the
specified epsilon. |
|
|
list
|
toListIfNot(obj)
Converts the given object to a list if it's not already one. |
|
|
set
|
toSetIfNot(obj)
Puts the given object(s) in a set if it's not already one. |
|
|
set
|
peekSet(s)
Extracts an arbitrary element in the set without removing it from the
set. |
|
|
bool
|
|
|
safeMakeDirs(path)
Creates a directory tree only if it doesn't already exists. |
|
|
str
|
|
|
|
str
|
getFileExtension(path)
Returns:
The file extension of the given path without the dot. |
|
|
str
|
getBasenameNoExt(path)
Gets the basename of the given file or directory path without its
extension. |
|
|
bool
|
|
str
|
|
str
|
normalizePath(path)
Platform independent os.path.normpath(): it recognizes both
forward and backward slashes and the result contains only forward
slashes. |
|
|
str
|
|
str
|
normalizePathSeparators(path)
Changes all backward slashes to forward slashes in the given path
which work on all platforms (including in Windows UNC paths). |
|
|
|
touch(path)
Touches a file. |
|
|
bool
|
|
bool
|
compareTrees(dir1,
dir2)
Compares two directory trees recursively |
|
|
|
rmtree(folder,
ignoreErrors=False)
Remove tree. |
|
|
tuple
|
parseSubCommand(args,
commands)
Utility function that parses the arguments expecting a subcommand
with its own set of arguments. |
|
|
|
bgTaskProgress(num,
denum)
Function used to indicate progress to a Composite parent running a
script as a background task. |
|
|
|
bgTaskProgressPercent(percent)
Function used to indicate progress to a Composite parent running a
script as a background task. |
|
|