{"id":25019501,"url":"https://github.com/aiidateam/archive-path","last_synced_at":"2025-07-04T12:32:12.300Z","repository":{"id":41853013,"uuid":"311011493","full_name":"aiidateam/archive-path","owner":"aiidateam","description":"A package to provide pathlib like access to zip \u0026 tar archives","archived":false,"fork":false,"pushed_at":"2022-11-30T20:14:13.000Z","size":76,"stargazers_count":7,"open_issues_count":7,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-03T10:47:37.856Z","etag":null,"topics":["archive","pathlib","tar","zip"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aiidateam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-08T07:49:34.000Z","updated_at":"2024-10-21T11:45:15.000Z","dependencies_parsed_at":"2022-08-11T19:30:54.619Z","dependency_job_id":null,"html_url":"https://github.com/aiidateam/archive-path","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/aiidateam/archive-path","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiidateam%2Farchive-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiidateam%2Farchive-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiidateam%2Farchive-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiidateam%2Farchive-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aiidateam","download_url":"https://codeload.github.com/aiidateam/archive-path/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiidateam%2Farchive-path/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263540978,"owners_count":23477454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","pathlib","tar","zip"],"created_at":"2025-02-05T11:50:49.819Z","updated_at":"2025-07-04T12:32:12.281Z","avatar_url":"https://github.com/aiidateam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# archive-path\n\n[![Build Status][ci-badge]][ci-link]\n[![codecov.io][cov-badge]][cov-link]\n[![PyPI version][pypi-badge]][pypi-link]\n[![Conda Version][conda-badge]][conda-link]\n\nA package to provide pathlib like access to zip \u0026 tar archives.\n\n## Installation\n\n```console\n$ pip install archive-path\n```\n\n## Usage\n\nFor reading zip (`ZipPath`) or tar (`TarPath`) files:\n\n```python\nfrom archive_path import TarPath, ZipPath\n\npath = TarPath(\"path/to/file.tar.gz\", mode=\"r:gz\")\n\nsub_path = path / \"folder\" / \"file.txt\"\nassert sub_path.filepath == \"path/to/file.tar.gz\"\nassert sub_path.at == \"folder/file.txt\"\nassert sub_path.exists() and sub_path.is_file()\nassert sub_path.parent.is_dir()\ncontent = sub_path.read_text()\n\nfor sub_path in path.iterdir():\n    print(sub_path)\n```\n\nFor writing files, you should use within a context manager, or directly call the `close` method:\n\n```python\nwith TarPath(\"path/to/file.tar.gz\", mode=\"w:gz\") as path:\n\n    (path / \"new_file.txt\").write_text(\"hallo world\")\n    # there are also some features equivalent to shutil\n    (path / \"other_file.txt\").putfile(\"path/to/external_file.txt\")\n    (path / \"other_folder\").puttree(\"path/to/external_folder\", pattern=\"**/*\")\n```\n\nNote that archive formats do not allow to overwrite existing files (they will raise a `FileExistsError`).\n\nFor performant access to single files:\n\n```python\nfrom archive_path import read_file_in_tar, read_file_in_zip\n\ncontent = read_file_in_tar(\"path/to/file.tar.gz\", \"file.txt\", encoding=\"utf8\")\n```\n\nThese methods allow for faster access to files (using less RAM) in archives containing 1000's of files.\nThis is because, the archive's file index is only read until the path is found (discarding non-matches),\nrather than the standard `tarfile`/`zipfile` approach that is to read the entire index into memory first.\n\n## Windows compatibility\n\nPaths within the archives are **always** read and written as being `/` delimited.\nThis means that the package works on Windows,\nbut will not be compatible with archives written outside this package with `\\\\` path delimiters.\n\n## Development\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to this package.\n\n[ci-badge]: https://github.com/aiidateam/archive-path/workflows/CI/badge.svg?branch=main\n[ci-link]: https://github.com/aiidateam/archive-path/actions?query=workflow%3ACI+branch%3Amain+event%3Apush\n[conda-badge]: https://img.shields.io/conda/vn/conda-forge/archive-path.svg\n[conda-link]: https://anaconda.org/conda-forge/archive-path\n[cov-badge]: https://codecov.io/gh/aiidateam/archive-path/branch/main/graph/badge.svg\n[cov-link]: https://codecov.io/gh/aiidateam/archive-path\n[pypi-badge]: https://img.shields.io/pypi/v/archive-path.svg\n[pypi-link]: https://pypi.org/project/archive-path\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiidateam%2Farchive-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiidateam%2Farchive-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiidateam%2Farchive-path/lists"}