Pybankreader API¶
pybankreader.exceptions module¶
- exception pybankreader.exceptions.ConfigurationError¶
Bases: exceptions.Exception
Exception signifies a programmers error in setting up the reports
pybankreader.fields module¶
- class pybankreader.fields.CharField(length, required)¶
Bases: pybankreader.fields.Field
CharField just uses the Field superclass directly for now, nothing special
- class pybankreader.fields.DecimalField(*args, **kwargs)¶
Bases: pybankreader.fields.RegexField
Decimal is just a special-case regex, so the field is implemented this way. Mind that when you’re using decimal, the overall length of the field must count with the decimal dot!
- class pybankreader.fields.Field(length, required)¶
Bases: object
Basic field superclass. We have mandatory length and required flags, and we hold the set value (if any). Also, the name of the field as defined in classes using these for reference reasons.
- field_name¶
Return the name of the field it has been assigned to
Return string: name of the field
- length = None¶
- required = None¶
- value¶
Just return the value, nothing special here
Returns: object
- class pybankreader.fields.IntegerField(*args, **kwargs)¶
Bases: pybankreader.fields.RegexField
Integer is just a special-case regex, so the field is implemented this way
- class pybankreader.fields.RegexField(regex, *args, **kwargs)¶
Bases: pybankreader.fields.Field
Generic regex field. On top of basic checks, enforces a regex match
- class pybankreader.fields.TimestampField(format, *args, **kwargs)¶
Bases: pybankreader.fields.Field
Timestamp field takes on format parameter to be fed into strptime
pybankreader.records module¶
- class pybankreader.records.FieldProxy(field_obj)¶
Bases: object
A decriptor class for fields. This essentially creates a proxy to attributes. Beware of weird class-level like behavior of descriptors
- class pybankreader.records.Record(initial=None)¶
Bases: object
The base Record class. Any record definition should use this one, since it allows for the smooth definition via class attributes and adds some facade methods to load those records.
Also, it uses the same trick as Field to mainatin it’s relative position inside the Report class
- load(data)¶
Parses the data using fields and loads it inside the record. If it throws a validation error, we reload initial values back to those fields
Parameters: data (string) – Data to be loaded by the record
- class pybankreader.records.RecordBase¶
Bases: type
The record metaclass. Mainly sets up Field proxy descriptors on Field instances (class attributes)
pybankreader.reports module¶
- class pybankreader.reports.CompoundRecord(*args)¶
Bases: pybankreader.records.Record
A wrapper for a record field that represents a list of records and possibly of multiple types of records. This is mainly required to control the position of individual record attributes in the given report.
- advance()¶
- get_record()¶
- reset()¶
- class pybankreader.reports.Report(file_like=None)¶
Bases: object
- data = None¶
- load(file_like)¶
Read individual records and assign them to proper instance fields, as they go. When the system cannot parse a record, we advance to the next record type first, before we raise an exception indicating that the report is invalid.
- class pybankreader.reports.ReportBase¶
Bases: type
The metaclass responsible for creating hint_<record> and process_<record> fields, as well as instantiating those in correct order and mapping them onto a Report instance.
pybankreader.utils module¶
- class pybankreader.utils.ProxyMixin(record)¶
Bases: object
A very simple proxy class that holds an object and proxies all attribute gets to that object. No setting of attributes allowed