cfinterface


Namecfinterface JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/rjmalves/cfi
SummaryInterface for handling custom formatted files
upload_time2024-04-12 20:29:59
maintainerNone
docs_urlNone
authorRogerio Alves
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements numpy pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cfinterface

![tests](https://github.com/rjmalves/cfi/workflows/tests/badge.svg)
[![codecov](https://codecov.io/gh/rjmalves/cfi/branch/main/graph/badge.svg?token=86ZXJGB854)](https://codecov.io/gh/rjmalves/cfi)

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.

```python
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](https://rjmalves.github.io/cfi).

## 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rjmalves/cfi",
    "name": "cfinterface",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Rogerio Alves",
    "author_email": "rogerioalves.ee@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9f/6f/906b3008013eef1bd7fc65e96bdc0558f3f75d7e22749ba580b55a275e0e/cfinterface-1.6.tar.gz",
    "platform": null,
    "description": "# cfinterface\n\n![tests](https://github.com/rjmalves/cfi/workflows/tests/badge.svg)\n[![codecov](https://codecov.io/gh/rjmalves/cfi/branch/main/graph/badge.svg?token=86ZXJGB854)](https://codecov.io/gh/rjmalves/cfi)\n\nPython package that contains a framework for dealing with custom file formats, modulating reading, data formatting and writing in a scalable and modular way.\n\n## Summary\n\n`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.\n\nSuppose 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:\n```\nDATA_HIGH  ID001   sudo.user  10/20/2025  901.25\n```\n\nIf `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.\n\n```python\nclass DATA_HIGH(Register):\n    IDENTIFIER = \"DATA_HIGH\"\n    IDENTIFIER_DIGITS = 9\n    LINE = Line(\n        [\n            LiteralField(size=6, starting_position=11),\n            LiteralField(size=9, starting_position=19),\n            DatetimeField(size=10, starting_position=30, format=\"%M/$d/%Y\"),\n            FloatField(size=6, starting_position=42, decimal_digits=2),\n        ]\n    )\n```\n\nA `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.\n\nDespite 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](https://rjmalves.github.io/cfi).\n\n## Install\n\n`cfinterface` requires python >= 3.7. It this requirement is met, than one may install the framework with\n```\npython -m pip install cfinterface\n```\n\n## Documentation\n\nGuides, tutorials and references may be found at the package's official site: https://rjmalves.github.io/cfi\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Interface for handling custom formatted files",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/rjmalves/cfi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a6eab9f2123dd84ddb4a76c0999c9fe794a959b90ae9dd6a574464e224b28e4",
                "md5": "eee879df2576e4f14e451ca9253218e8",
                "sha256": "1ee96b2f54f684463704b746a3930741701cd94a6a8780d484c60a20561941be"
            },
            "downloads": -1,
            "filename": "cfinterface-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eee879df2576e4f14e451ca9253218e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 57356,
            "upload_time": "2024-04-12T20:29:56",
            "upload_time_iso_8601": "2024-04-12T20:29:56.625801Z",
            "url": "https://files.pythonhosted.org/packages/8a/6e/ab9f2123dd84ddb4a76c0999c9fe794a959b90ae9dd6a574464e224b28e4/cfinterface-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f6f906b3008013eef1bd7fc65e96bdc0558f3f75d7e22749ba580b55a275e0e",
                "md5": "f85eba340b7e70e91c8347e040a3fda0",
                "sha256": "4eb5eb9bfe52eb1f4b68d7c14cd4e95aa903044e2d04f44d0164c76fb832a8bd"
            },
            "downloads": -1,
            "filename": "cfinterface-1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f85eba340b7e70e91c8347e040a3fda0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27467,
            "upload_time": "2024-04-12T20:29:59",
            "upload_time_iso_8601": "2024-04-12T20:29:59.177294Z",
            "url": "https://files.pythonhosted.org/packages/9f/6f/906b3008013eef1bd7fc65e96bdc0558f3f75d7e22749ba580b55a275e0e/cfinterface-1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 20:29:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rjmalves",
    "github_project": "cfi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        }
    ],
    "lcname": "cfinterface"
}
        
Elapsed time: 0.21523s