Package pyamf :: Module sol

[hide private]
[frames] | no frames]

# Module sol

source code

Local Shared Object implementation.

Local Shared Object (LSO), sometimes known as flash cookies, is a cookie-like data entity used by the Flash Player and Gnash. The players allow web content to read and write LSO data to the computer's local drive on a per-domain basis.

See Also:
  Local Shared Object on WikiPedia (external), Local Shared Object envelope (external)

Since: 0.1.0

Classes | [hide private]

| SOL Local Shared Object class, allows easy manipulation of the internals of a `sol` file.
| LSO Local Shared Object class, allows easy manipulation of the internals of a `sol` file.

Functions | [hide private]

`tuple`

decode(stream, strict=True) Decodes a SOL stream. | source code

BufferedByteStream

encode(name, values, strict=True, encoding=0) Produces a SharedObject encoded stream based on the name and values. | source code

load(name_or_file) Loads a sol file and returns a SOL object. | source code

save(sol, name_or_file, encoding=0) Writes a SOL object to `name_or_file`. | source code

Variables | [hide private]

| HEADER_VERSION = ``'``\x00\xbf``'`` Magic Number - 2 bytes
| HEADER_SIGNATURE = ``'``TCSO\x00\x04\x00\x00\x00\x00``'`` Marker - 10 bytes
| PADDING_BYTE = ``'``\x00``'`` Padding - 4 bytes

Imports: pyamf, util

Function Details | [hide private]

### decode(stream, strict=True)

source code

Decodes a SOL stream. `strict` mode ensures that the sol stream is as spec compatible as possible.

Parameters:
  - `strict` (`bool`) - Ensure that the SOL stream is as spec compatible as possible.
Returns: `tuple`
  A `tuple` containing the `root_name` and a `dict` of name, value pairs.
Raises:
  - `DecodeError` - Unknown SOL version in header.
  - `DecodeError` - Inconsistent stream header length.
  - `DecodeError` - Invalid signature.
  - `DecodeError` - Invalid padding read.
  - `DecodeError` - Missing padding byte.

### encode(name, values, strict=True, encoding=0)

source code

Produces a SharedObject encoded stream based on the name and values.

Parameters:
  - `name` (`basestring`) - The root name of the SharedObject.
  - `values` (`dict`) - A `dict` of name value pairs to be encoded in the stream.
  - `strict` (`bool`) - Ensure that the SOL stream is as spec compatible as possible.
Returns: BufferedByteStream
  A SharedObject encoded stream.

### load(name_or_file)

source code

Loads a sol file and returns a SOL object.

Parameters:
  - `name_or_file` (`str` or `StringIO`) - Name of file, or file-object.
Raises:
  - `ValueError` - Readable stream expected.

### save(sol, name_or_file, encoding=0)

source code

Writes a SOL object to `name_or_file`.

Parameters:
  - `sol` ()
  - `name_or_file` (`str` or `StringIO`) - Name of file, or file-object.
  - `encoding` (`int`) - AMF encoding type.
Raises:
  - `ValueError` - Writable stream expected.