Various utility functions go here.
|
|
|
|
|
containsAny(str,
set)
Check whether sequence str contains ANY of the items in set. |
source code
|
|
|
containsAll(str,
set)
Check whether sequence str contains ALL of the items in set. |
source code
|
|
|
containsOnly(str,
set)
Check whether sequence str contains ONLY items in set. |
source code
|
|
|
splitext(path)
Same as os.path.splitext() but faster. |
source code
|
|
|
updrive(path)
Make the drive letter (if any) upper case.
This is useful because Windows is inconsistent on the case
of the drive letter, which can cause inconsistencies when
calculating command signatures. |
source code
|
|
|
get_environment_var(varstr)
Given a string, first determine if it looks like a reference
to a single environment variable, like "$FOO" or "${FOO}".
If so, return that variable with no decorations ("FOO").
If not, return None. |
source code
|
|
|
render_tree(root,
child_func,
prune=0,
margin=[ 0] ,
visited=None)
Render a tree of nodes into an ASCII tree view. |
source code
|
|
|
|
|
print_tree(root,
child_func,
prune=0,
showtags=0,
margin=[ 0] ,
visited=None)
Print a tree of nodes. This is like render_tree, except it prints
lines directly instead of creating a string representation in memory,
so that huge trees can be printed. |
source code
|
|
|
is_Dict(obj,
isinstance=<built-in function isinstance>,
DictTypes=dict, UserDict) |
source code
|
|
|
is_List(obj,
isinstance=<built-in function isinstance>,
ListTypes=( <type 'list'>, <class 'UserList.UserList'>) ) |
source code
|
|
|
is_Sequence(obj,
isinstance=<built-in function isinstance>,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ) |
source code
|
|
|
is_Tuple(obj,
isinstance=<built-in function isinstance>,
tuple=<type 'tuple'>) |
source code
|
|
|
is_String(obj,
isinstance=<built-in function isinstance>,
StringTypes=( <type 'str'>, <type 'unicode'>, <class 'UserString.UserString'>) ) |
source code
|
|
|
is_Scalar(obj,
isinstance=<built-in function isinstance>,
StringTypes=( <type 'str'>, <type 'unicode'>, <class 'UserString.UserString'>) ,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ) |
source code
|
|
|
do_flatten(sequence,
result,
isinstance=<built-in function isinstance>,
StringTypes=( <type 'str'>, <type 'unicode'>, <class 'UserString.UserString'>) ,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ) |
source code
|
|
|
flatten(obj,
isinstance=<built-in function isinstance>,
StringTypes=( <type 'str'>, <type 'unicode'>, <class 'UserString.UserString'>) ,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ,
do_flatten=<__builtin__.function object>)
Flatten a sequence to a non-nested list. |
source code
|
|
|
flatten_sequence(sequence,
isinstance=<built-in function isinstance>,
StringTypes=( <type 'str'>, <type 'unicode'>, <class 'UserString.UserString'>) ,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ,
do_flatten=<__builtin__.function object>)
Flatten a sequence to a non-nested list. |
source code
|
|
|
to_String(s,
isinstance=<built-in function isinstance>,
str=<type 'str'>,
UserString=<class 'UserString.UserString'>,
BaseStringTypes=( <type 'str'>, <type 'unicode'>) ) |
source code
|
|
|
to_String_for_subst(s,
isinstance=<built-in function isinstance>,
str=<type 'str'>,
to_String=<__builtin__.function object>,
BaseStringTypes=( <type 'str'>, <type 'unicode'>) ,
SequenceTypes=( <type 'list'>, <type 'tuple'>, <class 'UserList.UserList'>) ,
UserString=<class 'UserString.UserString'>) |
source code
|
|
|
to_String_for_signature(obj,
to_String_for_subst=<__builtin__.function object>,
AttributeError=<type 'exceptions.AttributeError'>) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WhereIs(file,
path=None,
pathext=None,
reject=[ ] ) |
source code
|
|
|
PrependPath(oldpath,
newpath,
sep=' : ' ,
delete_existing=1,
canonicalize=None)
This prepends newpath elements to the given oldpath. Will only
add any particular path once (leaving the first one it encounters
and ignoring the rest, to preserve path order), and will
os.path.normpath and os.path.normcase all paths to help assure
this. This can also handle the case where the given old path
variable is a list instead of a string, in which case a list will
be returned instead of a string. |
source code
|
|
|
AppendPath(oldpath,
newpath,
sep=' : ' ,
delete_existing=1,
canonicalize=None)
This appends new path elements to the given old path. Will
only add any particular path once (leaving the last one it
encounters and ignoring the rest, to preserve path order), and
will os.path.normpath and os.path.normcase all paths to help
assure this. This can also handle the case where the given old
path variable is a list instead of a string, in which case a list
will be returned instead of a string. |
source code
|
|
|
AddPathIfNotExists(env_dict,
key,
path,
sep=' : ' )
This function will take 'key' out of the dictionary
'env_dict', then add the path 'path' to that key if it is not
already there. This treats the value of env_dict[key] as if it
has a similar format to the PATH variable...a list of paths
separated by tokens. The 'path' will get added to the list if it
is not already there. |
source code
|
|
|
get_native_path(path)
Transforms an absolute path into a native path for the system.
Non-Cygwin version, just leave the path alone. |
source code
|
|
|
|
|
|
|
adjustixes(fname,
pre,
suf,
ensure_suffix=False) |
source code
|
|
|
|
|
|
|
|
|
logical_lines(physical_lines,
joiner=<built-in method join of str object at 0x7fb7d4de6508>) |
source code
|
|
|
make_path_relative(path)
makes an absolute path name to a relative pathname. |
source code
|
|
|
AddMethod(obj,
function,
name=None)
Adds either a bound method to an instance or the function itself (or an unbound method in Python 2) to a class.
If name is ommited the name of the specified function
is used by default. |
source code
|
|
|
RenameFunction(function,
name)
Returns a function identical to the specified function, but with
the specified name. |
source code
|
|
|
MD5signature(s)
Generate a String of Hex digits representing the md5 signature of the string
:param s: either string or bytes. Normally should be bytes
:return: String of hex digits |
source code
|
|
|
|
|
|
|
silent_intern(x)
Perform sys.intern() on the passed argument and return the result.
If the input is ineligible (e.g. a unicode string) the original argument is
returned and no exception is thrown. |
source code
|
|
|
|
|
|
|
cmp(a,
b)
Define cmp because it's no longer available in python3
Works under python 2 as well |
source code
|
|
|
get_env_bool(env,
name,
default=False)
Get a value of env[name] converted to boolean. The value of env[name] is
interpreted as follows: 'true', 'yes', 'y', 'on' (case insensitive) and
anything convertible to int that yields non-zero integer are True values;
'0', 'false', 'no', 'n' and 'off' (case insensitive) are False values. For
all other cases, default value is returned. |
source code
|
|
|
get_os_env_bool(name,
default=False)
Same as get_env_bool(os.environ, name, default). |
source code
|
|