rozipinfo


Namerozipinfo JSON
Version 1.0.43 PyPI version JSON
download
home_pagehttps://github.com/gerph/python-zipinfo-riscos
SummaryManaging Zip archives with RISC OS filetype information present
upload_time2023-08-03 17:51:16
maintainer
docs_urlNone
authorCharles Ferguson
requires_python>=2.7
licenseBSD
keywords zip riscos
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python ZipInfo processing for RISC OS archives

This repository contains a pair of modules for handling the Zip archives with RISC OS information present.

The `rozipinfo` module provides a subclass of ZipInfo which is able to both parse the extra field used by RISC OS Zip archives, and generate these extra fields. This allows RISC OS archives to be worked with on non-RISC OS systems (or on RISC OS, if needed).

The `rozipfile` module builds on the `rozipinfo` module to allow the files to be extracted or created as a simple operation. It provide both a programatic and command line interface.

## Installing

The modules may be installed by copying them to where you need them, or through the package
manager:

    pip install rozipinfo

## `rozipinfo`

The `rozipinfo` module provides decoding for the RISC OS specific extra fields in the Zip Archives.
It can be used standalone as a module to convert the standard `zipfile.ZipInfo` objects into objects that have RISC OS properties extracted from the Zip file's extra field.

### Features

* Supports reading RISC OS style file properties, synthesised if necessary:
    * `riscos_filename`: RISC OS format filename, a `bytes` object in the configured encoding
    * `riscos_date_time`: tuple like `date_time`, but with centiseconds on the end
    * `riscos_objtype`: File or directory object type
    * `riscos_loadaddr`: Load address
    * `riscos_execaddr`: Exec address
    * `riscos_filetype`: RISC OS filetype number
    * `riscos_attr`: RISC OS attributes value
* Forces the `filename` to be unicode, having been decoded using the archive's encoding.
* All properties are mutable, and cause the extra field to be regenerated, updating the base properties as needed.
* Supports reading and writing the extra field, or using the NFS filename encoding format for transfer to other platforms.
* Configurable (by subclassing) encoding used for RISC OS filenames.
* Configurable (by subclassing) filetype inferrence rules, using extension, and parent directory name.
* Configurable (by subclassing) use of MimeMap module on RISC OS (not currently implemented, but the stub is there for overriding).

### Examples

The example code `showzip.py` demonstrates the use of the `ZipInfoRISCOS` module for reading zip archives.

For reading, it is expected that users will either enumerate objects in a zipfile and create a list of `ZipInfo` objects with `ZipFile.infolist()`, which they can then pass to `ZipInfoRISCOS` to handle the RISC OS specific extensions.

For writing, it is expected that users will create new `ZipInfoRISCOS` objects and pass these directly to the `ZipFile.writestr()` method.


## `rozipfile`

The rozipfile module builds upon the `rozipinfo` and works in a similar way to the regular `zipfile`.

### Listing files in the archive

The module allows the files to be listed as they might be in RISC OS:

    with RISCOSZipFile('ro-app.zip, 'r') as zh:
        zh.printdir()

The filenames can can be manually enumerated:

    with RISCOSZipFile('ro-app.zip, 'r') as zh:
        for zi in zh.infolist():
            print(zi.riscos_filename)


### Creating archives

The module allows the creation of archives of files on unix systems which are extractable on RISC OS with filetypes.

Creating a new zip archive containing an application directory and some files from the filesystem:

    with RISCOSZipFile('newzip.zip', 'w', base_dir='.') as rzh:
        rzh.add_dir('!MyApp')
        rzh.add_file('!MyApp/!Run,feb')
        rzh.add_file('!MyApp/!Sprites,ff9')
        rzh.add_file('!MyApp/!RunImage,ffb')

Or the files can be automatically traversed:

    with RISCOSZipFile('newzip.zip', 'w', base_dir='.') as rzh:
        rzh.add_to_zipfile('!MyApp')


### Extracting files from an archive

The module allows extracting the files from the RISC OS format archive, using the NFS filename
encoding.

    with RISCOSZipFile('ro-app.zip, 'r') as zh:
        zh.extractall(path='new-directory')

Individual files can alco be extracted, but filenames are in RISC OS format:

    with RISCOSZipFile('ro-app.zip, 'r') as zh:
        zh.extractall(path='!MyApp')


## Command line usage

The `rozipfile` module can be used to extract and create archives from the command line.

Listing an archive:

    python -m rozipfile --list <archive>

Creating an archive:

    python -m rozipfile [--chdir <dir>] --create <archive> <files>*

Extracting an archive:

    python -m rozipfile [--chdir <dir>] --extract <archive> <files>*

Producing a list of *SetType commands to restore filetypes from a badly extracted file:

    python -m rozipfile [--chdir <dir>] --settypes <archive>


### Default filetype

The default filetype for files that don't have any RISC OS extension information present (either as NFS-encoding or RISC OS extensions) is &FFD (Data). However, the switch `--default-filetype` can be used to default to a different type. Most commonly you may wish to set the default filetype to Text with `--default-filetype text`.


## Tests

Tests exist to show that the module is working properly, intended for use on GitLab.
Code coverage is about 84% at present; feature coverage is a bit lower, as not all the intended functionality is exercised by the tests.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gerph/python-zipinfo-riscos",
    "name": "rozipinfo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "zip,riscos",
    "author": "Charles Ferguson",
    "author_email": "gerph@gerph.org",
    "download_url": "https://files.pythonhosted.org/packages/11/84/0357c5b7bf948d8a6204c54c163cba3276a635ed5a124d99bef6ebe20a4a/rozipinfo-1.0.43.tar.gz",
    "platform": null,
    "description": "# Python ZipInfo processing for RISC OS archives\n\nThis repository contains a pair of modules for handling the Zip archives with RISC OS information present.\n\nThe `rozipinfo` module provides a subclass of ZipInfo which is able to both parse the extra field used by RISC OS Zip archives, and generate these extra fields. This allows RISC OS archives to be worked with on non-RISC OS systems (or on RISC OS, if needed).\n\nThe `rozipfile` module builds on the `rozipinfo` module to allow the files to be extracted or created as a simple operation. It provide both a programatic and command line interface.\n\n## Installing\n\nThe modules may be installed by copying them to where you need them, or through the package\nmanager:\n\n    pip install rozipinfo\n\n## `rozipinfo`\n\nThe `rozipinfo` module provides decoding for the RISC OS specific extra fields in the Zip Archives.\nIt can be used standalone as a module to convert the standard `zipfile.ZipInfo` objects into objects that have RISC OS properties extracted from the Zip file's extra field.\n\n### Features\n\n* Supports reading RISC OS style file properties, synthesised if necessary:\n    * `riscos_filename`: RISC OS format filename, a `bytes` object in the configured encoding\n    * `riscos_date_time`: tuple like `date_time`, but with centiseconds on the end\n    * `riscos_objtype`: File or directory object type\n    * `riscos_loadaddr`: Load address\n    * `riscos_execaddr`: Exec address\n    * `riscos_filetype`: RISC OS filetype number\n    * `riscos_attr`: RISC OS attributes value\n* Forces the `filename` to be unicode, having been decoded using the archive's encoding.\n* All properties are mutable, and cause the extra field to be regenerated, updating the base properties as needed.\n* Supports reading and writing the extra field, or using the NFS filename encoding format for transfer to other platforms.\n* Configurable (by subclassing) encoding used for RISC OS filenames.\n* Configurable (by subclassing) filetype inferrence rules, using extension, and parent directory name.\n* Configurable (by subclassing) use of MimeMap module on RISC OS (not currently implemented, but the stub is there for overriding).\n\n### Examples\n\nThe example code `showzip.py` demonstrates the use of the `ZipInfoRISCOS` module for reading zip archives.\n\nFor reading, it is expected that users will either enumerate objects in a zipfile and create a list of `ZipInfo` objects with `ZipFile.infolist()`, which they can then pass to `ZipInfoRISCOS` to handle the RISC OS specific extensions.\n\nFor writing, it is expected that users will create new `ZipInfoRISCOS` objects and pass these directly to the `ZipFile.writestr()` method.\n\n\n## `rozipfile`\n\nThe rozipfile module builds upon the `rozipinfo` and works in a similar way to the regular `zipfile`.\n\n### Listing files in the archive\n\nThe module allows the files to be listed as they might be in RISC OS:\n\n    with RISCOSZipFile('ro-app.zip, 'r') as zh:\n        zh.printdir()\n\nThe filenames can can be manually enumerated:\n\n    with RISCOSZipFile('ro-app.zip, 'r') as zh:\n        for zi in zh.infolist():\n            print(zi.riscos_filename)\n\n\n### Creating archives\n\nThe module allows the creation of archives of files on unix systems which are extractable on RISC OS with filetypes.\n\nCreating a new zip archive containing an application directory and some files from the filesystem:\n\n    with RISCOSZipFile('newzip.zip', 'w', base_dir='.') as rzh:\n        rzh.add_dir('!MyApp')\n        rzh.add_file('!MyApp/!Run,feb')\n        rzh.add_file('!MyApp/!Sprites,ff9')\n        rzh.add_file('!MyApp/!RunImage,ffb')\n\nOr the files can be automatically traversed:\n\n    with RISCOSZipFile('newzip.zip', 'w', base_dir='.') as rzh:\n        rzh.add_to_zipfile('!MyApp')\n\n\n### Extracting files from an archive\n\nThe module allows extracting the files from the RISC OS format archive, using the NFS filename\nencoding.\n\n    with RISCOSZipFile('ro-app.zip, 'r') as zh:\n        zh.extractall(path='new-directory')\n\nIndividual files can alco be extracted, but filenames are in RISC OS format:\n\n    with RISCOSZipFile('ro-app.zip, 'r') as zh:\n        zh.extractall(path='!MyApp')\n\n\n## Command line usage\n\nThe `rozipfile` module can be used to extract and create archives from the command line.\n\nListing an archive:\n\n    python -m rozipfile --list <archive>\n\nCreating an archive:\n\n    python -m rozipfile [--chdir <dir>] --create <archive> <files>*\n\nExtracting an archive:\n\n    python -m rozipfile [--chdir <dir>] --extract <archive> <files>*\n\nProducing a list of *SetType commands to restore filetypes from a badly extracted file:\n\n    python -m rozipfile [--chdir <dir>] --settypes <archive>\n\n\n### Default filetype\n\nThe default filetype for files that don't have any RISC OS extension information present (either as NFS-encoding or RISC OS extensions) is &FFD (Data). However, the switch `--default-filetype` can be used to default to a different type. Most commonly you may wish to set the default filetype to Text with `--default-filetype text`.\n\n\n## Tests\n\nTests exist to show that the module is working properly, intended for use on GitLab.\nCode coverage is about 84% at present; feature coverage is a bit lower, as not all the intended functionality is exercised by the tests.",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Managing Zip archives with RISC OS filetype information present",
    "version": "1.0.43",
    "project_urls": {
        "Homepage": "https://github.com/gerph/python-zipinfo-riscos"
    },
    "split_keywords": [
        "zip",
        "riscos"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11840357c5b7bf948d8a6204c54c163cba3276a635ed5a124d99bef6ebe20a4a",
                "md5": "d172361fb38d558a779bb0d383ce671f",
                "sha256": "5c8d04a99f4edc9550da65fabc03465c8e3ca59bb746e2b99fdc285061c273df"
            },
            "downloads": -1,
            "filename": "rozipinfo-1.0.43.tar.gz",
            "has_sig": false,
            "md5_digest": "d172361fb38d558a779bb0d383ce671f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 22911,
            "upload_time": "2023-08-03T17:51:16",
            "upload_time_iso_8601": "2023-08-03T17:51:16.944077Z",
            "url": "https://files.pythonhosted.org/packages/11/84/0357c5b7bf948d8a6204c54c163cba3276a635ed5a124d99bef6ebe20a4a/rozipinfo-1.0.43.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-03 17:51:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gerph",
    "github_project": "python-zipinfo-riscos",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rozipinfo"
}
        
Elapsed time: 1.28617s