135

dtrx: Intelligent archive extraction

 6 years ago
source link: https://brettcsmith.org/2007/dtrx/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

"Do The Right eXtraction" - don't remember what set of tar flags or where to pipe the output to extract it? no worries!

TL;DR

pip install dtrx

dtrx yolo.tar.gz

This is a copy-paste of the original dtrx repo, and all credit for this software should be attributed to the original author, Brett Smith @brettcs:

https://github.com/brettcs/dtrx

See the original README for more details on what this does!

Changes in this repo

This repo contains some patches on top of the original source to enable using dtrx with python3. The original motivation was to enable dtrx on Ubuntu 20.04+, where the dtrx apt package was removed from the default ppas (likely due to being python2 only).

I attempted to get the tests all working via tox , for which I used a Dockerfile to try to get some kind of environment consistency. You can run the tests by running (requires Docker installed):

./test.sh

Development

Contributions

Contributions are gladly welcomed! Feel free to open a Pull Request with any changes.

Issues

When posting an issue, it can be very handy to provide any example files (for example, the archive that failed to extract) or reproduction steps so we can address the problem quickly.

Releases

Releases are tagged in this repo and published to pypi.org. The release process for maintainers is the below steps:

  1. update the version specifier:

    # update the VERSION value in dtrx/dtrx.py, then:
    ❯ git add dtrx/dtrx.py
    ❯ git commit  # fill in the commit message
  2. create an annotated tag for the release. usually good to put a list of new commits since the previous tag, for example by listing them with:

    ❯ git log $(git describe --tags --abbrev=0)..HEAD --oneline
    # create the annotated tag
    ❯ git tag -a <version number>

    be sure to push the tag, git push --tags.

  3. use the make publish-release command to build and publish to GitHub and PyPi

See the Makefile for details on what that rule does.

Tests

There is a suite of tests that can be run either on the local python environment, or across all the supported python environments via docker:

# run the suite from the current python environment
pip install pyyaml  # test dependency
python tests/compare.py

# run the tests in docker across all supported python versions (takes a while)
./test.sh

# run the tests in docker on one python version
RUN_JOB=quick-test ./test.sh

Linting

Linting is provided by pre-commit. To use it, first install the pre-commit hook:

pip install pre-commit
pre-commit install

pre-commit will run anytime git commit runs (disable with --no-verify). You can manually run it with pre-commit run.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK