Skip to main content

A simple package to save a compressed directory

Project description

freezedry

A simple method to store a compressed copy of a code repository with customizable filtering of files.

PyPI version Documentation Status Python Versions License: MIT Tests codecov

Full Documentation | GitHub | PyPI

Do you ever wish you knew exactly which version of code you used when you made a figure, ran a job on a HPC cluster, or anything else? Freezedry is the solution!

With freezedry, you can easily save a compressed copy of an entire file directory that is designed to focus on code. Freezedry is a very simple package-- it only has one method you need to use (freezedry) that takes as input a path to a directory and a path to an output file, along with a few customizable optional input arguments.

What does freezedry include? Everything, if you don't specify. However, it's very easy to ignore:

  • git related files (i.e. anything with the pattern .git in the file path)
  • anything specified in a .gitignore file (thank you to Michael Herrmann) for the useful gitignore_parser package.
  • anything else you want (including exact string matches and regular expressions).

Installation

It's on PyPI. If there's any issues, please raise one on this GitHub repo to let me know.

pip install freezedry

Usage

Suppose that /..dirs../GitHub/your_repo contains some code you've been working on. And say you use the code in your_repo to do some analyses that are saved to /..dirs../results. Then, the following block of code will save a copy of your repo to the /results directory, ignoring any .git related files and ignoring anything in your .gitignore.

from freezedry import freezedry
directory_path = '/..dirs../GitHub/your_repo'
output_path = '/..dirs../results'
freezedry(directory_path, 
          output_path=output_path, 
          ignore_git=True, 
          use_gitignore=True, 
          verbose=True)

In addition, you can specify which files to ignore in two other ways:

  1. Direct match strings with extra_ignore. This is a list of strings, and if any string in the list is contained in a file, that file will be ignored. For example, if extra_ignore=['hi', 'world'] then '../hi/test.py' and '../myworld.py' will be ignored.

  2. Regular expression strings with regexp_ignore. This is a list of strings used as regular expressions. The rules are similar to extra_ignore, except that it uses the re.search method to find matches.

Setting the .gitignore

If .gitignore is not provided, then freezedry will look for it (non-recursively) in directory_path. Alternatively, you can provide a .gitignore directly with the optional argument gitignore_path. Note that you always have to set use_gitignore=True regardless of whether you provided a gitignore_path.

For example:

from freezedry import freezedry
directory_path = '/..dirs../GitHub/your_repo'
output_path = '/..dirs../results'
gitignore_path = '/..dirs../GitHub/my_other_repo/.gitignore'
freezedry(directory_path, 
          output_path=output_path, 
          ignore_git=True, 
          use_gitignore=True, # if False, won't use gitignore_path even if provided!!! 
          gitignore_path=gitignore_path, 
          verbose=True)

Documentation

For full documentation, check it out here. You'll find a complete API reference and more examples of how to use freezedry.

Contributing

I'm happy to take issues or pull requests, let me know if you have any ideas on how to make this better or requests for fixes.

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

freezedry-1.0.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freezedry-1.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file freezedry-1.0.0.tar.gz.

File metadata

  • Download URL: freezedry-1.0.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for freezedry-1.0.0.tar.gz
Algorithm Hash digest
SHA256 97abed8b22e28a27e9a4d0e09df7f23ec30ff05e92ae32f9fd43ea41c161b649
MD5 367d303dcad1da0b6a05cc4d4e11a2a1
BLAKE2b-256 c7ff49a386f376a93730b13a98ac199f59bd9596fd0fbda74d49406183fad464

See more details on using hashes here.

File details

Details for the file freezedry-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: freezedry-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for freezedry-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 164e50392427240b9977592e4e02a8df511c6d91c0946a128c5e53897a69ed6b
MD5 4804db3bc532b72b795c38e066faf04e
BLAKE2b-256 fad1265013921f38c1e6da3c491dcab045260ceb4fd1695e12a1d5db8476d3ee

See more details on using hashes here.

Supported by

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