Package csb :: Package io

[frames] | no frames]

# Package io

source code

Generic I/O utility objects.

Here is a list of the most essential classes in this module:

1. temporary file system objects: TempFile, TempFolder
2. special/decorated streams: MemoryStream, AutoFlushStream
3. reusable stream readers and writers: EntryReader, EntryWriter
4. convenient communication with the shell: Shell

In addition, csb.io is also part of the CSB compatibility layer. In order to ensure cross-interpreter compatibility, always use the following csb.io objects:

- MemoryStream instead of (c)StringIO
- csb.io.Pickle instead of pickle or cPickle
- csb.io.urllib instead of urllib or urllib.request

See also csb.core for additional notes on compatibility.

Submodules

- csb.io.plots: Plotting facilities, based on Python's MPL library.
- csb.io.tsv: Read, query and update textual tables via flexible SQL interface.

Classes
| AutoFlushStream Wrapper around a buffered stream which automatically calls flush() after each write().
| EntryReader Generic flatfile reader.
| EntryWriter A simple stream writer.
| InvalidCommandError Raised when Shell.run() encounters an OSError.
| MemoryStream In-memory stream object.
| ProcessError Raised on Shell.run() failures.
| Shell
| ShellInfo Shell command execution info
| TempFile Create a temporary file and take care of deleting it upon object destruction.
| TempFolder Create a temporary directory which is automatically wiped when the object is closed.
| TimeoutError Raised on Shell.run() timeouts.

Functions

dump(this, filename, gzip=False, lock=None, timeout=None) Writes a python object to a file, using python cPickle Supports also '~' or '~user'. | source code

load(filename, gzip=False, lock=None, timeout=None) Unpickle an object from filename | source code

Variables
| NEWLINE = ``'``\n``'``
| __package__ = ``'``csb.io``'``

Function Details

### dump(this, filename, gzip=False, lock=None, timeout=None)

source code

Writes a python object to a file, using python cPickle Supports also '~' or '~user'.

Parameters:
  - `this` (Any python object) - The object, which will be written to disk
  - `filename` (String) - Filename of the new file
  - `gzip` (Boolean) - Use gzip to compress the file
  - `lock` - Use a lockfile to restrict access

### load(filename, gzip=False, lock=None, timeout=None)

source code

Unpickle an object from filename

Parameters:
  - `filename` - Filename pickled object
  - `gzip` (Boolean) - Use gzip to uncompress the file
  - `lock` - Use a lockfile to restrict access
Returns:
  Python object unpickled from file