Code Monkey home page Code Monkey logo

arpy's Introduction

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

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)

arpy's People

Contributors

charles0830 avatar

Stargazers

Bobby Ray avatar Ankit Prakash avatar Ming Yao avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.