Skip to main content

Command line utilities for creating zip files

Project description

zip-files

Source code on Github zip-files on the Python Package Index Travis Continuous Integration AppVeyor Continuous Integration Coveralls BSD License

Command line utilities for creating zip files.

Provides the zip-files and zip-folder command line utilities. These are intended as an easy platform-independent tool to create zip files with an arbitrary file name and an arbitrary root (the top-level folder after extracting a zip) from files and folders at arbitrary locations on the file system.

Typical usage includes:

  • Deploy zip archives of Sphinx-documentation while releasing Python packages:

    zip-folder --auto-root --outfile docs/_build/artifacts/mypackage-v1.0.0.zip docs/_build/html

    creates a file mypackage-v1.0.0.zip in docs/_build/artifacts that unzips as a folder mypackage-v1.0.0 containing the files originally in docs/_build/html/.

  • Create zip files pulled together from different locations, for emailing:

    zip-files -a -o report.zip ./report2020-01.tex /scratch/project/plots/*.pdf

    creates a file report.zip that unzips as a folder report containing the file report2020-01.tex and all the pdf files originally in /scratch/project/plots/.

    zip-files -f report2020-01 -o report.zip ./report2020-01.tex /scratch/project/plots/*.pdf

    does the same, but unzips as a folder report2020-01 instead of report.

Development of zip-files happens on Github.

Installation

To install the latest released version of zip-files, run this command in your terminal:

pip install zip_files

This is the preferred method to install zip-files, as it will always install the most recent stable release. It will result in the executable commands zip-files and zip-folder being added to your environment’s bin folder.

Usage

zip-files

Usage: zip-files [OPTIONS] [FILES]...

  Create a zip file containing FILES.

Options:
  -h, --help                      Show this message and exit.
  --version                       Show the version and exit.
  --debug                         Activate debug logging.
  -f, --root-folder ROOT_FOLDER   Folder name to prepend to FILES inside the
                                  zip file.

  -c, --compression [stored|deflated|bzip2|lzma]
                                  Zip compression method. The following
                                  methods are available: "stored": no
                                  compression; "deflated": the standard zip
                                  compression method; "bzip2": BZIP2
                                  compression method (part of the zip standard
                                  since 2001); "lzma": LZMA compression method
                                  (part of the zip standard since 2006).
                                  [default: deflated]

  -a, --auto-root                 If given in combination with --outfile, use
                                  the stem of the OUTFILE (without path and
                                  extension) as the value for ROOT_FOLDER

  -x, --exclude GLOB_PATTERN      Glob-pattern to exclude. This is matched
                                  from the right against all paths in the zip
                                  file, see Python pathlib's Path.match
                                  method. This option can be given multiple
                                  times.

  -X, --exclude-from FILE         File from which to read a list of glob-
                                  patterns to exclude, cf. --exclude. Each
                                  line in FILE is one pattern. This option can
                                  be given multiple times.

  --exclude-dotfiles / --include-dotfiles
                                  Whether or not to include dotfiles in the
                                  zip files. By default, dotfiles are
                                  included.

  --exclude-vcs / --include-vcs   Whether or not to include files and
                                  directories commonly used by version control
                                  systems. (Git, CVS, RCS, SCCS, SVN, Arch,
                                  Bazaar, Mercurial, and Darcs), e.g.
                                  '.git/', '.gitignore' '.gitmodules'
                                  '.gitattributes' for Git. By default, VCS
                                  are included.

  --exclude-git-ignores / --include-git-ignores
                                  Whether or not to look for .gitignore files
                                  and to process them for exclude patterns.
                                  Note that the .gitignore file itself is
                                  still included in the zip archive unless
                                  --exclude-vcs is given. By default,
                                  .gitignore files are not processed.

  -o, --outfile OUTFILE           The path of the zip file to be written. By
                                  default, the file is written to stdout.

zip-folder

Usage: zip-folder [OPTIONS] FOLDER

  Create a zip file containing the FOLDER.

Options:
  -h, --help                      Show this message and exit.
  --version                       Show the version and exit.
  --debug                         Activate debug logging.
  -f, --root-folder ROOT_FOLDER   Folder name to use as the top level folder
                                  inside the zip file (replacing FOLDER).

  -c, --compression [stored|deflated|bzip2|lzma]
                                  Zip compression method. The following
                                  methods are available: "stored": no
                                  compression; "deflated": the standard zip
                                  compression method; "bzip2": BZIP2
                                  compression method (part of the zip standard
                                  since 2001); "lzma": LZMA compression method
                                  (part of the zip standard since 2006).
                                  [default: deflated]

  -a, --auto-root                 If given in combination with --outfile, use
                                  the stem of the OUTFILE (without path and
                                  extension) as the value for ROOT_FOLDER

  -x, --exclude GLOB_PATTERN      Glob-pattern to exclude. This is matched
                                  from the right against all paths in the zip
                                  file, see Python pathlib's Path.match
                                  method. This option can be given multiple
                                  times.

  -X, --exclude-from FILE         File from which to read a list of glob-
                                  patterns to exclude, cf. --exclude. Each
                                  line in FILE is one pattern. This option can
                                  be given multiple times.

  --exclude-dotfiles / --include-dotfiles
                                  Whether or not to include dotfiles in the
                                  zip files. By default, dotfiles are
                                  included.

  --exclude-vcs / --include-vcs   Whether or not to include files and
                                  directories commonly used by version control
                                  systems. (Git, CVS, RCS, SCCS, SVN, Arch,
                                  Bazaar, Mercurial, and Darcs), e.g.
                                  '.git/', '.gitignore' '.gitmodules'
                                  '.gitattributes' for Git. By default, VCS
                                  are included.

  --exclude-git-ignores / --include-git-ignores
                                  Whether or not to look for .gitignore files
                                  and to process them for exclude patterns.
                                  Note that the .gitignore file itself is
                                  still included in the zip archive unless
                                  --exclude-vcs is given. By default,
                                  .gitignore files are not processed.

  -o, --outfile OUTFILE           The path of the zip file to be written. By
                                  default, the file is written to stdout.

History

0.4.0 (2020-04-04)

  • Added: opions --exclude-vcs, --exclude-git-ignores, and --exclude-vcs

0.3.0 (2020-01-19)

  • Added: option --exclude

0.2.0 (2020-01-17)

  • Added: option --auto-root

0.1.0 (2020-01-17)

  • Initial release

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

zip_files-0.4.0.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

zip_files-0.4.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file zip_files-0.4.0.tar.gz.

File metadata

  • Download URL: zip_files-0.4.0.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.1

File hashes

Hashes for zip_files-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d2a68c27864fe9321639f436db75f4f5938878acc61618ab7b864d027dce46c8
MD5 c0f5a4cf5f3413b69b8b792205fdc736
BLAKE2b-256 d26842096c6536e50c1164e96eb4dd1fe8640bd578d7f43bf61cf1872aae65dc

See more details on using hashes here.

File details

Details for the file zip_files-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: zip_files-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.1

File hashes

Hashes for zip_files-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40a4c8ae8257154fe1e79fbcec69e61f9100749aba2997aafcfc84a6a03d1d90
MD5 92d3b17400ed820061b1e559c462987a
BLAKE2b-256 69a69219ebab8cbac248ca16f86af8eda5d577913744278d274721633a6eca6c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page