EBML Library
Extensible Binary Meta Language read/write/modify library for Python
|
view on
github
|
This is an Extensible Binary Meta Language library library for use with Python 2.x and 3.x. Its primary goal is to provide ease of use and minimal memory usage.
The following section documents the public API of the classes and functions which are useful under normal circumstances. Modifying objects using other methods may break the internal state of an EBML document.
The extended descriptions are minimized by default for ease of locating functions by name. Click the +/− or the function name to expand/shrink the description. (expand all | shrink all)
The following functions are available in the module and are used for encoding/decoding file-like streams.
ebml.(element, stream, pointers_temporary=True...)
element : ebml.Element
stream : input_stream
pointers_temporary : boolean
The Schema
object is used to define the semantic information for decoding and validating an EBML document.
Schema.(id, name, el_type, level="g", versions=0, validator=None, pointer=False...) : ebml.ElementDescriptor
id : list | tuple | string | bytes
list
or tuple
, each entry of the object will be treated as a byte.string
, each set of 2
characters will be treated as a hexadecimal byte.bytes
object, each character will be treated as a byte.name : string
el_type : TYPE_CONSTANT
level : string | integer
"g"
, then it can appear anywhere in the document."#+"
, then it can appear on level #
and deeper. (it is recursive)versions : integer
0
, it can appear in any version.validator : function
True
if it's valid, and False
otherwisepointer : boolean
True
if this value should be loaded as a pointer (the reading of its value from the input stream will be deferred), or False
otherwisereturn : ebml.ElementDescriptor
Schema.(name, value=None...) : ebml.Element
name : string | ebml.ElementDescriptor
ebml.ElementDescriptor
returned from a .define
call, it creates an element of the descriptor's type.value : any
.set
functionreturn : ebml.Element
Schema.() : ebml.ElementContainer
return : ebml.ElementContainer
The following functions are available on all Element
instances.
However, certain functions may not be implemented for certain subclasses, so they may raise exceptions.
Element.(decode_depth=-1...) : any
decode_depth : integer
0
indicates only the element itself should be decoded, all child elements will be pointers.1
indicates only element and its first level children should be decoded, all other elements will be pointers...return : any
Element.(element, before=None, after=None, prepend=False...)
self
object is not a container element, an exception will be raised.element : ebml.Element
before : ebml.Element
None
, the element will be inserted before this child element.after : ebml.Element
before
is None
, and the value is not None
, the element will be inserted after this child element.prepend : boolean
before
and after
are both None
, this parameter specifies where the new element should be inserted.False
, it's inserted after all of the children as the last element.True
, it's inserted before all of the children as the first element.The following class is used to provide high-precision date objects for encoding/decoding dates.
ebml.ElementDate.(year, month, day, hour=0, minute=0, second=0, nanoseconds=0...) : ebml.ElementDate.Date
year : integer
month : integer
day : integer
hour : integer
minute : integer
second : integer
nanoseconds : integer
return : ebml.ElementDate.Date
EBML selectors are similar to CSS selectors, and are used to easily select elements out of a document. The exact syntax of a valid selector string will not be described, as it is mostly identical to the standard CSS selectors.
The following are the available selectors:
3n+1
, n+4
, n
, 4
"int"
represents ebml.INT
elements
Selector.(element...) : ebml.Element | None