gavo.grammars.columngrammar module¶
A grammar that just splits the source into input lines and then lets you name character ranges.
- class gavo.grammars.columngrammar.ColRangeAttribute(name, **kwargs)[source]¶
Bases:
UnicodeAttribute
A range of indices.
Ranges can be specified as either <int1>-<int2>, just <int> (which is equivalent to <int>-<int>), or as half-open ranges (<int>- or -<int>) Ranges are, contrary to python slices, inclusive on both sides, and start counting from one.
- class gavo.grammars.columngrammar.ColumnGrammar(parent, **kwargs)[source]¶
Bases:
Grammar
,FileRowAttributes
A grammar that builds rowdicts out of character index ranges.
This works by using the colRanges attribute like <col key=”mag”>12-16</col>, which will take the characters 12 through 16 inclusive from each input line to build the input column mag.
As a shortcut, you can also use the colDefs attribute; it contains a string of the form {<key>:<range>}, i.e., a whitespace-separated list of colon-separated items of key and range as accepted by cols, e.g.:
<colDefs> a: 3-4 _u: 7 </colDefs>
- attrSeq = [<gavo.base.attrdef.ActionAttribute object>, <gavo.base.complexattrs.DictAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.BooleanAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.complexattrs.PropertyAttribute object>, <gavo.rscdef.common.RDAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.attrdef.BooleanAttribute object>, <gavo.base.attrdef.IntAttribute object>]¶
- clearProperty(name)¶
- completedCallbacks = []¶
- getFullId()¶
- getProperty(name, default=<Undefined>)¶
- hasProperty(name)¶
- managedAttrs = {'col': <gavo.base.complexattrs.DictAttribute object>, 'colDefs': <gavo.base.attrdef.ActionAttribute object>, 'colRanges': <gavo.base.complexattrs.DictAttribute object>, 'commentIntroducer': <gavo.base.attrdef.UnicodeAttribute object>, 'enc': <gavo.base.attrdef.UnicodeAttribute object>, 'gunzip': <gavo.base.attrdef.BooleanAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'ignoreOn': <gavo.base.complexattrs.StructAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'preFilter': <gavo.base.attrdef.UnicodeAttribute 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>, 'sourceFields': <gavo.base.complexattrs.StructAttribute object>, 'strip': <gavo.base.attrdef.BooleanAttribute object>, 'topIgnoredLines': <gavo.base.attrdef.IntAttribute object>}¶
- name_ = 'columnGrammar'¶
- property rd¶
- rowIterator¶
alias of
SplitLineIterator
- setProperty(name, value)¶
- class gavo.grammars.columngrammar.SplitLineIterator(grammar, sourceToken, **kwargs)[source]¶
Bases:
FileRowIterator