Interface for handling custom formatted files
Project description
cfinterface
Python package that contains a framework for dealing with custom file formats, modulating reading, data formatting and writing in a scalable and modular way.
Summary
cfinterface
is a framework for designing low-level interfaces that depends on complex text or binary file parsing. It provides components for modeling lines, registers, blocks and sections in a declarative way and aggregate these blocks as components for defining files.
Suppose that a complex text file needs to be parsed and the contents of lines with a specific identifier must be extracted and validated. For instance, the line follows the format:
DATA_HIGH ID001 sudo.user 10/20/2025 901.25
If DATA_HIGH
is the identifier that specifies the lines to be read, than one can model it with the Register
class in the cfinterface
framework.
class DATA_HIGH(Register):
IDENTIFIER = "DATA_HIGH"
IDENTIFIER_DIGITS = 9
LINE = Line(
[
LiteralField(size=6, starting_position=11),
LiteralField(size=9, starting_position=19),
DatetimeField(size=10, starting_position=30, format="%M/$d/%Y"),
FloatField(size=6, starting_position=42, decimal_digits=2),
]
)
A Register
depends on the definition of a Line
object, that is composed of Field
objects. By modeling these elements on a declarative way, the user gains access to reading / writing functions on the fly, and the Register
may be added to a RegisterFile
object, so that it can be read / written together with many other registers to files.
Despite the Register
model, files can also be composed of Blocks
and Sections
, and their interfaces can be done to text
or binary
formats. For more information, the docs are available here.
Install
cfinterface
requires python >= 3.7. It this requirement is met, than one may install the framework with
python -m pip install cfinterface
Documentation
Guides, tutorials and references may be found at the package's official site: https://rjmalves.github.io/cfi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cfinterface-1.7.1.tar.gz
.
File metadata
- Download URL: cfinterface-1.7.1.tar.gz
- Upload date:
- Size: 27.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61a148fb81a8b1b1e8e1779346af6168861f38f8740a82390b4fe8278be0c705 |
|
MD5 | e42d4afd087ad6f66a4f947267632eea |
|
BLAKE2b-256 | 4411e78bf6d2add5a6b8d77127c36a513733ee3248d7a3a2a2d01c19e324896c |
File details
Details for the file cfinterface-1.7.1-py3-none-any.whl
.
File metadata
- Download URL: cfinterface-1.7.1-py3-none-any.whl
- Upload date:
- Size: 57.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64db285f357babd051df858ad2f52f7f67b367afbd8746c59465a08a116a2d03 |
|
MD5 | 761ffdbb421d8b5f69256ec5cd308c95 |
|
BLAKE2b-256 | 4a03e98806639d93ca67e069835a936b7e968b72720b0f4f349c05425286e177 |