Main API

class wcf.records.Record(type=None)
classmethod add_records(records)

adds records to the lookup table

Parameters:records (list(Record)) – list of Record subclasses
classmethod parse(fp)

Parses the binary data from fp into Record objects

Parameters:fp – file like object to read from
Returns:a root Record object with its child Records
Return type:Record
>>> from wcf.records import *
>>> from StringIO import StringIO as io
>>> buf = io('A\x01a\x04test\x01')
>>> r = Record.parse(buf)
>>> r
[<ElementRecord(type=0x41)>]
>>> str(r[0])
'<a:test >'
>>> dump_records(r)
'A\x01a\x04test\x01'
>>> _ = print_records(r)
<a:test ></a:test>
to_bytes()

Generates the representing bytes of the record

>>> from wcf.records import *
>>> Record(0xff).to_bytes()
'\xff'
>>> ElementRecord('a', 'test').to_bytes()
'A\x01a\x04test'
wcf.records.dump_records(records)[source]

returns the byte representation of a given record tree

Parameters:records (wcf.records.Record) – the record tree
Returns:a bytestring
Return type:str
wcf.records.print_records(records, skip=0, fp=None, first_call=True)[source]

prints the given record tree into a file like object

Parameters:
  • records (wcf.records.Record) – a tree of record objects
  • skip (int) – start value for intending (Default: 0)
  • fp – file like object to print to (Default: sys.stdout)
class wcf.xml2records.XMLParser[source]
classmethod parse(data)[source]

Parses a XML String/Fileobject into a Record tree

Parameters:data – a XML string or fileobject
Returns:a Record tree
>>> from wcf.records import dump_records, print_records
>>> from wcf.xml2records import XMLParser
>>> r = XMLParser.parse('<s:Envelope><b:Body /></s:Envelope>')
>>> dump_records(r)
'V\x02E\x0e\x01\x01'
>>> b = print_records(r)
<s:Envelope >
 <b:Body ></b:Body>
</s:Envelope>

Previous topic

Python Library for de- and encoding of WCF-Binary streams

Next topic

Available Records

This Page