Skip to main content

Python library for handling fixed sized files, with interactive CLI

Project description

FixedSizeFileIOTools

Python library for handling fixed sized files (120 characters), with interactive CLI.

Contents

Library on this Repo consist of 3 main files.

  • models.py - consist of pydantict models for object structures.

    • Functionalites:

      • Three seperate models:

        • Header - Represents a header with specific fields. (name, surname, patronymic, address)
        • Transaction - Represents a transaction with a specific fields. (counter, amount, currency, reserved)
        • Footer - Represents a footer with specific fields. (total counter, control sum, reserved)
      • Methods:

        1. get_header() - get all fields of header with formated lengths.
        2. get_transaction()- get all fields of transaction with formated lengths.
        3. get_footer() - get all fields of footer with formated lengths.
        4. get_field() - get any field of model.
        5. change_field() - change field of model.
        6. close_field() - close field for modification.
        7. open_field() - open field for modification.
        8. is_field_modifiable() - check is field modifiable.
        9. decimal_places() - check if provided amount in transaction has more than 3 decimal places.
        10. currency_must_be_from_list() - check if provided currency is from predifined list.
  • file_handler.py - Handles fixed-format files containing headers, transactions, and footers.

    • Functionalites:

      • Methods:

        1. init: Initializes the FixedFileHandler object.
        2. validate_file_structure(): Validates the structure of the input file.
        3. validate_records_structure(): Validates the structure of the records stored in the dictonary.
        4. read_records(): Reads records from the input file and stores them in the records dictionary.
        5. write_records(): Writes records stored in the object to an output file.
        6. add_new_transaction(): Adds a new transaction to the records dictionary.
        7. add_header(): Adds a header record to the records dictionary.
        8. list_transactions(): Lists all transactions stored in the records dictionary.
  • cli.py - Interactive Command-line interface for handling files with fixed length (120 characters in line) records.

    This CLI provides commands for reading, writing, modifying records and generating sample files.

    Usage: Use the function run() to start the interactive CLI.

    • Commands:
      1. read: Read records from a file.
      2. write: Write records to a file.
      3. add-header: Add a header record.
      4. add-transaction: Add a transaction record.
      5. list-transactions: List current transactions.
      6. get-field: Get the value of a specific field from a record.
      7. change-field: Change the value of a specific field in a record.
      8. open-field: Open a field for modification.
      9. close-field: Close a field for modification.
      10. clear-all: Clear all current stored information (not from file).
      11. generate-sample_file: Generate a sample file with transactions.
      12. help: Show available commands.

Tests

This library was throughly tested using pytest in edge scenarios / cases.

To run tests just write pytest -vv in terminal at root directory of this project.

Distribution

You can install and use this library free at

https://pypi.org/project/FixedSizeFileIOTools/

Author

Patryk Jaworki

17.04.2024

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FixedSizeFileIOTools-1.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FixedSizeFileIOTools-1.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file FixedSizeFileIOTools-1.1.tar.gz.

File metadata

  • Download URL: FixedSizeFileIOTools-1.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for FixedSizeFileIOTools-1.1.tar.gz
Algorithm Hash digest
SHA256 d6011e2d4917a49c606fac3202dd09003e28f16eb41d9259ea9ce4cfd78f6978
MD5 ee84a9a556591f71aef0b8c1dc7cb2d9
BLAKE2b-256 159996ea691e71812edb03379f0594ae88eb505b7b2f1a0a4a4fa76c564e542a

See more details on using hashes here.

File details

Details for the file FixedSizeFileIOTools-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for FixedSizeFileIOTools-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c6b945a503815d0ebc515f4b82477b2505189d1cd114c31a3a8fc170655fa69
MD5 8bb4dd33cd98cf2f6c45920c63c45aa2
BLAKE2b-256 13db123197f504c2c5c8dcbbde885adc10b2ef62c72afa3bbf0077a8efb0030a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page