core
- The basics¶
The core package contains general purpose modules and building blocks for the other library packages.
abstract
- Additions to the abc standard module¶
Helpers for the standard abc
module.
-
class
abstractstatic
(function)[source]¶ Decorator that combines
staticmethod
andabc.abstractmethod
.Copied from this answer to this StackOverflow question.
async_subprocess
- Subprocesses with non-blocking I/O¶
Allow asynchronous interaction with a subprocess.
This module was taken from this recipe in the ActiveState Code Recipes 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
On Windows pywin32 is required.
-
class
AsyncPopen
(cmd, encoding=None, **kwargs)[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.
-
__init__
(cmd, encoding=None, **kwargs)[source]¶ Execute cmd in a subprocess, using encoding to convert to and from binary data written or read from/to the subprocess’s input, output and error streams.
Additional keyword arguments are as specified by
subprocess.Popen.__init__()
method.
-
-
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¶
Backup a file or directory to make editing reversible.
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
BackupDir
(dir_, ext='.BAK', mode=1)[source]¶ Move or copy a directory that needs to be recreated or modified.
-
__exit__
(exc_type, exc_val, exc_tb)[source]¶ When the controlling with statement is exited normally discard the backup directory, otherwise restore it to its original place.
-
__init__
(dir_, ext='.BAK', mode=1)[source]¶ Prepare to backup the dir_ directory.
The backup will be created in dir_’s parent directory, which must be writable, with extension ext. If mode is MOVE, the default, the original directory will be moved to the backup destination; if mode is COPY it will be copied there.
-
-
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.
-
__exit__
(exc_type, exc_val, exc_tb)[source]¶ When the controlling with statement is exited normally discard the backup file, otherwise restore it to its original place.
-
__init__
(file_, ext='.BAK', dir='.', mode=2)[source]¶ Prepare to backup file_, either a file-like object or a path.
The backup file will be created in directory dir with extension ext. If mode is COPY the original file will be copied to the backup destination; if mode is MOVE it will be moved there.
-
close
()[source]¶ Close the backup file and release the corresponding reference.
The backup file may not be reopened.
-
name
¶ The name of the file to be backed up.
-
-
exception
NotSavedError
[source]¶ Raised when commit or rollback is called on an inactive BackUpFile or BackUpDirectory.
error
- nxpy
’s exception hierarchy¶
Exception classes.
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.
file
- File related utilities¶
File related utilities.
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.
past
- Python version support enforcement¶
Identification and enforcement of supported Python releases.
-
class
Version
(version)[source]¶ Identifies a Python release in a way that is convenient for comparison and printing.
path
- File system related utilities¶
filesystem related utilities.
-
class
CurrentDirectory
(path)[source]¶ A context manager that allows changing the current directory temporarily.
-
current
¶ Return the current directory.
-
-
blasttree
(dir_)[source]¶ Remove a directory more stubbornly than
shutil.rmtree()
.Required on filesystems that do not allow removal of non-writable files
sequence
- Sequence related utilities¶
Utility functions that deal with non-string sequences.
sort
- Sorting functions¶
Sort functions.
temp_file
- Temporary files that support the context protocol¶
Temporary files and directories.
Requires at least Python 2.6
-
class
TempDir
(*args, **kwargs)[source]¶ A temporary directory that implements the context manager protocol.
The directory is removed when the context is exited from. Uses
tempfile.mkdtemp()
to create the actual directory.-
name
¶ Return the directory name.
-
-
class
TempFile
(*args, **kwargs)[source]¶ A temporary file that implements the context manager protocol.
Wrap a
tempfile.NamedTemporaryFile()
generated file-like object, to ensure it is not deleted on close, but rather when the underlying context is closed.-
name
¶ Return the actual file name.
-