core - The basics
The core package contains general purpose modules and building blocks for the other library
packages.
async_subprocess - Subprocesses with non-blocking I/O
Allow asynchronous interaction with a subprocess.
This module was taken from the ASPN Python Cookbook website, with only minor
modifications. This is the original description:
Title: Module to allow Asynchronous subprocess use on Windows and Posix platforms
Submitter: Josiah Carlson (other recipes)
Last Updated: 2006/12/01
Version no: 1.9
Category: System
-
class AsyncPopen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0)[source]
An asynchronous variant to ‘subprocess.Popen’, which doesn’t block on incomplete I/O
operations.
Note that the terms input, output and error refer to the controlled program streams,
so we receive from output or error and we send to input.
-
get_conn_maxsize(which, maxsize)[source]
Return ‘which’ output pipe (either stdout or stderr) and ‘maxsize’ constrained to the
[1, 1024] interval in a tuple.
-
recv(maxsize=None)[source]
Receive at most ‘maxsize’ bytes from the subprocess’s standard output
-
recv_err(maxsize=None)[source]
Receive at most ‘maxsize’ bytes from the subprocess’s standard error
-
send(input)[source]
Send ‘input’ to the subprocess’s standard input.
-
send_recv(input='', maxsize=None)[source]
Send ‘input’ to the subprocess’s standard input and then receive at most ‘maxsize’ bytes
from both its standard output and standard error.
-
recv_some(p, t=0.1, e=1, tr=5, stderr=0)[source]
Try and receive data from AsyncPopen object ‘p’’s stdout in at most ‘tr’ tries and with a
timeout of ‘t’. If ‘stderr’ is True receive from the subprocess’s stderr instead.
-
send_all(p, data)[source]
Send all of ‘data’ to AsyncPopen object ‘p’’s stdin.
backup_file - File objects with automated backup
A file with automatic backup.
Implement the context manager protocol, so as to be suitable to be used with
the ‘with’ statement. When used in this fashion changes are discarded when an
exception is thrown.
-
class BackupFile(file, ext='.BAK', dir='.', mode=2)[source]
Implements a read only file object used to automatically back up a file that has to be
modified.
-
close()[source]
Close the backup file and release the corresponding reference.
The backup file may not be reopened.
-
commit()[source]
Discard the backup, i.e. keep the supposedly modified file.
-
name[source]
The name of the file to be backed up.
-
open(mode=4)[source]
Open the backup file for reading. ‘mode’ may be either ‘TEXT’ or ‘BINARY’.
-
rollback()[source]
Replace the original file with the backup copy.
-
save()[source]
Create a backup copy of the original file.
-
exception MissingBackupError[source]
raised when a backup file isn’t found
-
exception NotSavedError[source]
Raised when commit or rollback is called on an inactive BackUpFile
-
exception RemovalError[source]
Raised to signal errors in the removal of backup files
error - nxpy‘s exception hierarchy
Exception classes.
-
exception ArgumentError[source]
Raised when a function receives an invalid argument
file_object - Stubs for read-only and modifiable file-like objects
Helper classes for the implementation of read-only and writable file objects that forward calls
to an actual file object variable.
-
class ReadOnlyFileObject(file=None)[source]
Implement the non modifying portion of the file object protocol by delegating to
another file object.
Subclass and override as needed.
-
setFile(file)[source]
Set the delegate file object.
-
class WritableFileObject(file=None)[source]
Implement the file object protocol by delegating to another file object.
Subclass and override as needed.
file - File related utilities
File related utilities.
-
compare(file1, file2, ignore_eof=True)[source]
Compare two text files for equality.
If ignore_eof is True, end of line characters are not considered.
memo - Memoize objects according to a given key
Memoize class instances according to a given key.
By default the key only assumes the ‘True’ value, thus implementing a singleton.
-
class Memo[source]
Base class for classes that require memoization.
Care should be taken to avoid calling __init__() again for entities already constructed.
sequence - Sequence related utilities
Utility functions that deal with non-string sequences.
-
make_tuple(arg)[source]
An alternate way of creating tuples from a single argument.
A single string argument is turned into a single element tuple and a dictionary argument is
turned into a tuple of its items. Otherwise it works like the standard tuple constructor.
sort - Sorting functions
Sort functions.
-
topological_sort(pairs)[source]
Provide a topological ordering of the supplied pair elements.
‘pairs’ is a sequence of two element sequences, in which the first element comes before
the second according to the desired ordering criterium.
temp_file - Temporary files that support the context protocol
Temporary files and directories.
-
class TempDir(*args, **kwargs)[source]
A temporary directory that implements the context manager protocol.
The directory is removed when the context is exited from.
-
class TempFile(*args, **kwargs)[source]
A temporary file that implements the context manager protocol.
The file is removed when the context is exited from.