Extensible Binary Meta Language read/write/modify library for Python
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 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
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
tuple, each entry of the object will be treated as a byte.
string, each set of
2characters will be treated as a hexadecimal byte.
bytesobject, 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
Trueif it's valid, and
pointer : boolean
Trueif this value should be loaded as a pointer (the reading of its value from the input stream will be deferred), or
return : ebml.ElementDescriptor
Schema.(name, value=None...) : ebml.Element
name : string | ebml.ElementDescriptor
ebml.ElementDescriptorreturned from a
.definecall, it creates an element of the descriptor's type.
value : any
return : ebml.Element
Trueif the schema is allowed to decode data into pointers, or
Falseif pointers should not be allowed
0, no version checking is performed. Otherwise, it is performed as a bitwise
&operator: if the
&'d value is not
0, the element's version is considered valid
The following functions are available on all
However, certain functions may not be implemented for certain subclasses, so they may raise exceptions.
Element.(decode_depth=-1...) : any
decode_depth : integer
0indicates only the element itself should be decoded, all child elements will be pointers.
1indicates 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...)
selfobject 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
None, and the value is not
None, the element will be inserted after this child element.
prepend : boolean
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: