pyre.records¶
Submodules¶
Package Contents¶
-
pyre.records.field¶
-
pyre.records.measure¶
-
pyre.records.derivation¶
-
pyre.records.literal¶
-
pyre.records.bool¶
-
pyre.records.decimal¶
-
pyre.records.float¶
-
pyre.records.inet¶
-
pyre.records.int¶
-
pyre.records.identity¶
-
pyre.records.str¶
-
pyre.records.date¶
-
pyre.records.dimensional¶
-
pyre.records.time¶
-
pyre.records.uri¶
-
pyre.records.converter¶
-
pyre.records.normalizer¶
-
pyre.records.validator¶
-
class
pyre.records.selector(index, field, **kwds)¶ The base class for objects responsible for providing named access to field descriptors
-
index¶
-
field¶
-
__get__(self, record, cls)¶ Field retrieval
-
-
class
pyre.records.templater(name, bases, attributes, **kwds)¶ Bases:
pyre.patterns.AttributeClassifier.AttributeClassifierMetaclass that inspects record declarations and endows their instances with the necessary infrastructure to support
- named access of the fields in a record
- composition via inheritance
- derivations, i.e. fields whose values depend on the values of other fields
-
class
pyre.records.record¶ Bases:
pyre.framework.Dashboard.DashboardThe base class for representing data extracted from persistent stores.
Records have field descriptors that provide the information necessary to convert data between the representation used by the persistent store and the native python object required by the application.
Records are similar to named tuples: the underlying storage mechanism is a tuple, and the fields are descriptors that provide named access to the tuple items. They are superior to named tuples since they enable the data model designer to specify types and constraints that must be satisfied by the data, and automate the conversion process to a large degree.
Inheritance among {Record} subclasses is interpreted as composition: the set of fields that define a record is built out of the descriptors declared both locally and by all of its ancestors. Descriptor composition is subject to name shadowing.
Records support {derivations}: fields whose value is computed using other record fields. Such fields are built automatically whenever a field declaration contains any sort of arithmetic on the right hand side.
Details of the current implementation:
- Storage for the record values is provided by {tuple}. This implies that indexed access using integers works as expected and does not require any special handling
- Named access is handled through the field descriptors. Supporting composition via inheritance complicates the implementation a bit, as the rank of a given field is not known until the class mro is traversed and shadowing is taken into account. Each {Record} subclass maintains its own map from descriptor instances to the integer rank in the corresponding underlying tuple.
-
pyre_name¶
-
pyre_localFields¶
-
pyre_fields¶
-
pyre_measures¶
-
pyre_derivations¶
-
pyre_columns¶
-
class
pyre.records.csv¶ A reader and writer of records in csv format
This class enhances the support provided by the csv package from the python standard library by reading and writing records that have a variety of metadata attached to their fields, which enables much smarter processing of the information content.
-
immutable(self, layout, uri=None, stream=None, **kwds)¶ Build mutable record instances from a csv formatted source
-
mutable(self, layout, uri=None, stream=None, **kwds)¶ Build mutable record instances from a csv formatted source
-
read(self, layout, uri=None, stream=None, **kwds)¶ Read lines from a csv formatted input source
The argument {layout} is expected to be a subclass of {pyre.records.Record}. It will be inspected to extract the names of the columns to ingest.
If {uri} is not None, it will be opened for reading in the manner recommended by the {csv} package; if {stream} is given instead, it will be passed directly to the {csv} package. The first record is assumed to be headers that name the columns of the data.
-
write(self, sheet, uri=None, stream=None, **kwds)¶ Read lines from a csv formatted input source
The argument {sheet} is expected to be a subclass of {pyre.records.Record}. It will be inspected to extract the names of the columns to save.
If {uri} is not None, it will be opened for writing in the manner recommended by the {csv} package; if {stream} is given instead, it will be passed directly to the {csv} package
-