private.utils

Uncategorised utilities.

This is a mess of stuff, which should get tidied up in the short term.

Module Members

addProjectSourceToSysPath()
addThisProjectSourceToSysPath()
dumpStack()
findFileAbove()
getCallerDict()
trimLines()
trimText()

Classes

class private.utils.Partial(func, *args, **kwargs)

Enhanced form of functools.partial.

This allows the arguments to be modified, using update(), before the partial function is invoked.

update(*args, **kwargs)

Add positional args and/or modify keyword args.

Arguments

args
All positional arguments are added to the existing set. Some cases may make use of positional arguments, but mostly only keyword args are provided.
kwargs
All keyword arguments are used to update the existing set.
class private.utils.preserveCWD

Context manager to undo and os.chdir calls.

The current working directory in effect before context entry is restored when the context exits.

digraph foo {
rankdir=BT;
ranksep=0.3;
node[fontsize=10 margin=0.01 height=0.2 width=0.4];
edge[arrowsize=0.6 arrowhead=onormal];
"cstest.private.utils.preserveCWD" [color=blue height=0.4 width=0.6];
    "cstest.private.utils.temporaryCWD" -> "cstest.private.utils.preserveCWD";
}

Subclass: temporaryCWD

class private.utils.temporaryCWD(targetDirectory)

Context manager to temporarily change the current working directory.

The CWD is chaged when the context is entered. The current working directory in effect before context entry is restored when the context exits.

digraph foo {
rankdir=BT;
ranksep=0.3;
node[fontsize=10 margin=0.01 height=0.2 width=0.4];
edge[arrowsize=0.6 arrowhead=onormal];
"cstest.private.utils.temporaryCWD" [color=blue height=0.4 width=0.6];
    "cstest.private.utils.temporaryCWD" -> "cstest.private.utils.preserveCWD";
}

Base class: preserveCWD