Package spoon :: Package ber
[hide private]
[frames] | no frames]

Package ber

source code

The low level BER based encoding used by spoon to serialize objects.

Users of the spoon library will probably not need to use this package at all.

Submodules [hide private]

Classes [hide private]
  BERException
  Tag
Representation of the header of an ASN.1 object.
  BERStream
FIXME docs
  encoder
  zencoder
  decoder

Functions [hide private]
  encode_container(fd, tag, items)
Encode a list of items into a container with the given tag and write it to a stream.
list decode_container(fd, tag)
Decode a container into a list of items.
  encode_stream(fd, *items)
Encode one or more python objects into a ber stream, written to the given file object.
  decode_stream(fd)
Decode a ber-encoded python object from a file object and return it.
  encode(*items)
Encode one or more python objects into a ber stream, and return the encoded string.
  decode(s)
Decode a python object from a ber-encoded string and return it.

Variables [hide private]
  UNIVERSAL = 0
  APPLICATION = 1
  CONTEXT = 2
  PRIVATE = 3
  EOF_TYPE = <ASN.1 Tag(UNIVERSAL, 0, size=0, container=False)>
  NULL_TYPE = <ASN.1 Tag(UNIVERSAL, 5, size=None, container=False)>
  INT_TYPE = <ASN.1 Tag(UNIVERSAL, 2, size=None, container=False)>
  BYTES_TYPE = <ASN.1 Tag(UNIVERSAL, 4, size=None, container=False)>
  UTF8_TYPE = <ASN.1 Tag(UNIVERSAL, 12, size=None, container=False)>
  LIST_TYPE = <ASN.1 Tag(UNIVERSAL, 16, size=None, container=True)>
  __module__ = 'spoon'
  x = <ASN.1 Tag(UNIVERSAL, 16, size=None, container=True)>

Function Details [hide private]

encode_container(fd, tag, items)

source code 
Encode a list of items into a container with the given tag and write it to a stream. The list is written using indefinite-length encoding, so no extra copying occurs.
Parameters:
  • fd (file) - the file object to write into
  • tag (Tag) - the tag to use for this list
  • items (list or iterable) - a list of items to put into the container

decode_container(fd, tag)

source code 
Decode a container into a list of items.
Parameters:
  • fd (file) - the file object to read from
  • tag (Tag) - the tag from the container
Returns: list
a list of decoded objects

encode_stream(fd, *items)

source code 
Encode one or more python objects into a ber stream, written to the given file object.

decode_stream(fd)

source code 
Decode a ber-encoded python object from a file object and return it.

encode(*items)

source code 
Encode one or more python objects into a ber stream, and return the encoded string.

decode(s)

source code 
Decode a python object from a ber-encoded string and return it.

Variables Details [hide private]

UNIVERSAL

None
Value:
0                                                                     
      

APPLICATION

None
Value:
1                                                                     
      

CONTEXT

None
Value:
2                                                                     
      

PRIVATE

None
Value:
3                                                                     
      

EOF_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 0, size=0, container=False)>                     
      

NULL_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 5, size=None, container=False)>                  
      

INT_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 2, size=None, container=False)>                  
      

BYTES_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 4, size=None, container=False)>                  
      

UTF8_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 12, size=None, container=False)>                 
      

LIST_TYPE

None
Value:
<ASN.1 Tag(UNIVERSAL, 16, size=None, container=True)>                  
      

__module__

None
Value:
'spoon'                                                                
      

x

None
Value:
<ASN.1 Tag(UNIVERSAL, 16, size=None, container=True)>