Skip to main content

Configurable iterator-based access to compressed files.

Project description

compressed_file_iterator

Configurable iterator-based access to compressed files.

This is a simple package to provide configurable iterator-based access to compressed files.

Usage:

foo.json

{
    ".gz": {
        "base_command": {
            "posix": "/bin/gzip"
        },
        "base_options": {
            "posix": [ '-d', '-c', ]
        },
        "type": "Gzip"
    },
    ".*": {
        "base_command": {
            "posix": "/bin/cat"
        },
        "base_options": {
            "posix": []
        },
        "type": "Plain"
    }
}
import compressed_file_iterator
# ...
    my_iterator = compressed_file_iterator.MyIterator(
                                                      'foo.txt',
                                                      config_file='foo.json',
                                                      case_sensitive=True,
                                                      )

    for line in my_iterator:
        print(line)
# ...

Installation

TODO: (Upload to allow for install via pip.)

$ pip install compressed_file_iterator

Documentation

Class definition

class compressed_file_iterator():
        def __init__(self, 
                     args, 
                     cwd='./',
                     config_file='compressed_file_iterator.json',
                     case_sensitive=True,
                     ):

Parameters

  • args : list
    • Contains file name to open.
  • cwd : string, optional
    • Working directory. (Default: '.').
  • config_file : string, optional
    • JSON configuration defining extensions and how to handle them.
  • case_sensitive : boolean, optional
    • Perform match attempts against JSON configuration in a case-sensitive manner. If False, process via string.casefold() before testing. (Default: True)

JSON Format

{
        '.extension': {
                'base_command': {
                    os_name: path_to_executable,
                },
                'base_options': {
                        os_name: [ command_line_options ],
                'type': string
        },
}

Parameters

  • .extension: string
    • A string representation of a file extension, as separated by pathlib.Path().suffixes.
    • A default definition should be included for '.*' to be used if no other match can be made.
  • base_command: dictionary
    • Contains one or more commands, indexed by the value of os.name on the system.
  • base_options: dictionary
    • Contains one or more lists consisting of zero or more options required by the appropriate base_command to output content on STDOUT. Indexed by the value of os.name.
  • type: string
    • String identifier for the compression configuration. (Currently unused.)

Acknowledgements

  • To my friend, Chris Jones, for suggesting I add the option of case-insensitive extension matching.
  • To the members of #python on the Libera.Chat IRC network, for patiently enduring my numerous questions.

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

compressed_file_iterator-0.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

compressed_file_iterator-0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file compressed_file_iterator-0.0.1.tar.gz.

File metadata

File hashes

Hashes for compressed_file_iterator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f34e7151e86979bf5e8cba303bea331cbba1c7ac0afee371af5b2ff717f49c59
MD5 ad54862d2c1160243e4c9ed8f0b2e976
BLAKE2b-256 ea76627e1c6d3bfc24cd862d0984bd47218ebb3c8ee7c2b654eb4e3d8263f0be

See more details on using hashes here.

File details

Details for the file compressed_file_iterator-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for compressed_file_iterator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba7a5e382c1370acfa27a37003fba67fd16c0bc5ac10f403cdc7ca5fd6a1f04
MD5 cc344521899546d6a26944f9ab2ed2d0
BLAKE2b-256 31a064415d7f004d6c74cf12b5972d356d3a082dd592aed4e5d589d3e7267304

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