pingspice.util
module documentation
Part of pingspice
Generally useful stuff that's referenced by most modules of pingspice
. Highlights:
-
The
sub
function really should be a built-in function. Once you start using it, you'll never go back toformat
. -
The
Config
object holds global Boolean configuration options. There are actually quite a few of them, and you'll probably refer to this a lot. -
The
msg
instance of the ade package's Messenger object provides a very convenient and flexible way to put messages onto a log file, file-like object, or STDOUT. -
The
oops
function is a handy universal errback to tack onto aDeferred
. -
The
tempfile
function creates the directory for or removes a temporary file using a module-level instance ofTempfileManager
, which tries to delete all its files when Python shuts down. -
Construct a
Formatter
instance for a few methods that ensure your node names conform with Ngspice canonical format and your values are all strings with Booleans converted to "1" or "0".
Function | brace | Does a sub of proto and args and returns the result wrapped in braces ("{x}"). |
Function | npr | Returns the args, except with the first two reversed if keyword
reverse is set True . |
Function | notseq | Returns True if x is not a sequence. |
Function | plural | Undocumented |
Function | tryCall | Tries running f(*args, **kw ), returning the result. Drops
to the debugger if the call results in an error. |
Function | oops | A handy universal errback. |
Function | deferToThread | Call this with a callable f and any args or kw it
takes to have it run in a dedicated worker thread. Returns a
Deferred that fires with the eventual result. |
Class | Formatter | I provide a few methods that ensure your node names conform with Ngspice canonical format and your values are all strings with Booleans converted to "1" or "0". |
Class | Bag | Use an instance of me to let functions within methods have easy access to stuff defined in the main method body. |
Class | TempfileManager | I manage temporary files in my temporary file subdirectory, attempting to remove all the ones I've created when Python shuts down. |
Function | tempfile | Creates the directory for or removes a temporary file using a
module-level instance of TempfileManager ,
which tries to delete all its files when Python shuts down. |
Class | SlotPickleMixin | Copied from http://code.activestate.com/recipes/ 578433-mixin-for-pickling-objects-with-__slots__/ |
Class | Config | I hold a set of Boolean configuration options for an entire pingspice
run. Request an option as an attribute. The value will be
False if not set. |
Class | _Debug | Undocumented |
Does a sub of proto and args and returns the result wrapped in braces ("{x}").
Returns the args, except with the first two reversed if keyword
reverse is set True
.
Tries running f(*args, **kw
), returning the result. Drops
to the debugger if the call results in an error.
A handy universal errback.
Prints or logs the failure's error message and then, unless
keepGoing is set True
, stops everything so you can
figure out what went wrong.
Call this with a callable f and any args or kw it
takes to have it run in a dedicated worker thread. Returns a
Deferred
that fires with the eventual result.
Creates the directory for or removes a temporary file using a
module-level instance of TempfileManager
,
which tries to delete all its files when Python shuts down.
Call with the full path of a temporary file generated during this Python
session and it gets deleted, unless the register keyword is set
True
. In that case, the full path gets registered for deletion
when Python shuts down.
Call with an extension (a string beginning with or lacking a dot) and a
unique temp file path is returned with that extension, in the temp
directory (newly created if necessary). Unless the keep keyword is
set True
, any file created at that path will be deleted when
Python shuts down.