CACHEDIR.TAG for Python
This library handles CACHEDIR.TAG files. Allowing any arbitrary directory to be marked as a cache directory.
A CACHEDIR.TAG file indicates a directory that contain cached data, e.g.
- downloads
- previews, and thumbnails
- build artefacts, and other intermediate results
Cached data is useful, but not essential - if necessary it can be regenerated, or downloaded again. However backup programs, disk cleanup utilities, & other software can't know if an arbitrary path is cached data, unless it is marked.
A directory (and all directories within it) can be marked as a cache by writing a regular file named CACHEDIR.TAG, with the first 43 bytes being
Signature: 8a477f597d28d172789f06886806bc55
After this signature any other text can be included. The specification
suggests lines of text beginning with #, encoded as UTF-8. E.g.
# This file is a cache directory tag created by (application name).
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/
This library follows that suggestion.
Installation
$ python -m pip install cachedir-tag
Usage
Create your cache directory, if necessary
>>> import os, cachedir_tag
>>> os.mkdir('/var/cache/yourapp')
Tag it, this creates a new CACHEDIR.TAG file
>>> cachedir_tag.tag('/var/cache/yourapp')
Check whether the directory is tagged
>>> cachedir_tag.is_tagged('/var/cache/yourapp')
True
Check whether a sub-directory (which may not exist yet) is tagged
>>> cachedir_tag.is_tagged('/var/cache/yourapp/somedir')
True
License
MIT
Alternatives
Operating systems and similar platforms usually have conventions about where to place cached data. A CACHEDIR.TAG file isn't needed if you follow these conventions, but it doesn't hurt either.
More information
Metadata
Release files for cachedir-tag 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cachedir_tag-0.0.5.tar.gz | 4.6 kB | Without provenance | Details for cachedir_tag-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cachedir_tag-0.0.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for cachedir_tag-0.0.5-py2.py3-none-any.whl |
Total release size: 8.6 kB
Release files / cachedir_tag-0.0.5.tar.gz
| Download URL | cachedir_tag-0.0.5.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40ea1bffff8de77de7e094f70624805b2a6c5b989982094a5db4e684763a86e1
|
|
BLAKE2b-256 checksum How to use checksums |
c4cca4836b21108573851b701a3137b16eebfd589e5bdff569f5f5173af36bfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.14
|
Release files / cachedir_tag-0.0.5-py2.py3-none-any.whl
| Download URL | cachedir_tag-0.0.5-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
18af8e157251ab916277978f4337070820aced9503ce3a59171a1c296facc0fc
|
|
BLAKE2b-256 checksum How to use checksums |
baccb994cf19817f738739de6a9a0574370a1d5cd192c025fc5f5afa5c68b5d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.14
|
Security for cachedir-tag 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.