stingray package implements a Schema-based File Reader.
This allows us to use flat-file and workbook data from Python without having
to clone an application for each physical file format or logical layout.
It also allows us to use semi-structured data like JSON, YAML or an outline. This can be handled consistently with structured data.
This package includes
- A definition for “workbook”, “sheet” and “cell”. This can subsume
xlrdas well as XML parsers for XLSX and ODS files. This makes the physical format transparent to an application.
- A definition for a schema. Not a complex XSD, but the limited, flat schema appropriate for rows in sheets of a workbook in approximately First Normal Form. This is extended to handle the simple hierarcical COBOL features.
- Classes to load a schema that’s embedded either in a sheet or in a separate file.
- A COBOL schema loader as an extension to the default loaders.
This depends on Python 3.3.
The structure of the
stingray package is as follows.
__init__.py. Some essential overhead. See stingray __init__.py.
cell.py. Cell Module – Data Element Containers and Conversions defines the
Cellclass hierarchy. Imported as
sheet.py. Sheet Module – Sheet and Row Access defines the
Sheetclass hierarchy that supports sheets with embedded as well as external schema. Imported as
workbook.py. The Workbook Package – Uniform Wrappers for Workbooks families. Imported as
schema. This package defines a schema and schema loaders.
__init__.py. Schema Package – Schema and Attribute Definitions. Imported as
stingray.schema. This is the generic, flat schema and superclasses for the more complex COBOL schema.
loader.py. Schema Loader Module – Load Embedded or External Schema. A loader for the generic, flat schema. Imported as
stingray.schema.loader. Applications will often extend schema loaders to handle peculiar formats or multi-line headings or other workbook formatting.
cobol. This package extends a schema and schema loaders to handle COBOL files.
__init__.py. The COBOL Package. Imported as
stingray.cobol. These are extensions to
loader.pyCOBOL Loader Module – Parse COBOL Source to Load a Schema. A loader for COBOL-syntax schema. Imported as
defs.py. COBOL Definitions Module – Handle COBOL DDE’s. Base definitions used by both
snappy. This module is a minimal implementation of a reader for files written with Snappy compression.
protobuf. This module is a minimal implementation of a reader for objects represented using protobuf.