Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viraptor/arpy
https://github.com/viraptor/arpy
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/viraptor/arpy
- Owner: viraptor
- Created: 2013-03-24T02:16:23.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-14T08:58:13.000Z (11 months ago)
- Last Synced: 2024-09-19T12:38:01.993Z (3 months ago)
- Language: Python
- Size: 108 KB
- Stars: 12
- Watchers: 3
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Arpy
====This library can be used to access **ar** files from python. It's tested to work with python 3.5+ and pypy3. (for earlier pythons see version <2) Travis status: [![Build Status](https://travis-ci.org/viraptor/arpy.png)](https://travis-ci.org/viraptor/arpy)
It supports both GNU and BSD formats and exposes the archived files using the standard python **file** interface.
Usage
=====Standard file usage:
--------------------With context managers:
with arpy.Archive('file.ar') as ar:
print("files: %s" % ar.namelist())
with ar.open('content.txt') as f:
print(f.read())Via headers for duplicate names:
with arpy.Archive('file.ar') as ar:
for header in ar.infolist():
print("file: %s" % header.name)
with ar.open(header) as f:
print(f.read())Or directly:
ar = arpy.Archive('file.ar'))
ar.read_all_headers()# check all available files
ar.archived_files.keys()# get the contents of the archived file
ar.archived_files[b'some_file'].read()Stream / pipe / ... usage:
--------------------------ar = arpy.Archive('file.ar'))
for f in ar:
print("got file name: %s" % f.header.name)
print("with contents: %s" % f.read())Contributions
=============All contributions welcome. Just make sure that:
* tests are provided
* all current platforms are passing (tox configuration is provided)
* coverage is close to 100% (currently only missing statements are those depending on python version being used)