gavo.grammars.binarygrammar module¶
A grammar reading from (fixed-record) binary files.
-
class
gavo.grammars.binarygrammar.
BinaryGrammar
(parent, **kwargs)[source]¶ Bases:
gavo.grammars.common.Grammar
A grammar that builds rowdicts from binary data.
The grammar expects the input to be in fixed-length records. the actual specification of the fields is done via a binaryRecordDef element.
-
attrSeq
= [<gavo.base.attrdef.EnumeratedUnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.complexattrs.PropertyAttribute object>, <gavo.rscdef.common.RDAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.attrdef.IntAttribute object>]¶
-
clearProperty
(name)¶
-
completedCallbacks
= []¶
-
getFullId
()¶
-
getProperty
(name, default=<Undefined>)¶
-
hasProperty
(name)¶
-
managedAttrs
= {'armor': <gavo.base.attrdef.EnumeratedUnicodeAttribute object>, 'binaryRecordDef': <gavo.base.complexattrs.StructAttribute object>, 'enc': <gavo.base.attrdef.UnicodeAttribute object>, 'fieldDefs': <gavo.base.complexattrs.StructAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'ignoreOn': <gavo.base.complexattrs.StructAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'properties': <gavo.base.complexattrs.PropertyAttribute object>, 'property': <gavo.base.complexattrs.PropertyAttribute object>, 'rd': <gavo.rscdef.common.RDAttribute object>, 'rowfilter': <gavo.base.complexattrs.StructListAttribute object>, 'rowfilters': <gavo.base.complexattrs.StructListAttribute object>, 'skipBytes': <gavo.base.attrdef.IntAttribute object>, 'sourceFields': <gavo.base.complexattrs.StructAttribute object>}¶
-
name_
= 'binaryGrammar'¶
-
property
rd
¶
-
rowIterator
¶
-
setProperty
(name, value)¶
-
-
class
gavo.grammars.binarygrammar.
BinaryRecordDef
(parent, **kwargs)[source]¶ Bases:
gavo.base.structure.Structure
A definition of a binary record.
A binary records consists of a number of binary fields, each of which is defined by a name and a format code. The format codes supported here are a subset of what python’s struct module supports. The widths given below are for big, little, and packed binfmts. For native (which is the default), it depends on your platform.
<number>s – <number> characters making up a string
b,B – signed and unsigned byte (8 bit)
h,H – signed and unsigned short (16 bit)
i,I – signed and unsigned int (32 bit)
q,Q – signed and unsigned long (64 bit)
f,d – float and double.
The content of this element gives the record structure in the format <name>(<code>){<whitespace><name>(<code>)} where <name> is a c-style identifier.
-
attrSeq
= [<gavo.base.attrdef.EnumeratedUnicodeAttribute object>, <gavo.base.structure.DataContent object>, <gavo.base.parsecontext.IdAttribute object>]¶
-
completedCallbacks
= []¶
-
managedAttrs
= {'binfmt': <gavo.base.attrdef.EnumeratedUnicodeAttribute object>, 'content_': <gavo.base.structure.DataContent object>, 'id': <gavo.base.parsecontext.IdAttribute object>}¶
-
name_
= 'binaryRecordDef'¶
-
class
gavo.grammars.binarygrammar.
BinaryRowIterator
(grammar, sourceToken, **kwargs)[source]¶ Bases:
gavo.grammars.common.FileRowIterator
A row iterator reading from binary files.
-
fileMode
= 'rb'¶
-