Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sivel/iter_tar
Python library to iterate through a tar file
https://github.com/sivel/iter_tar
Last synced: about 1 month ago
JSON representation
Python library to iterate through a tar file
- Host: GitHub
- URL: https://github.com/sivel/iter_tar
- Owner: sivel
- License: mit
- Created: 2022-02-04T17:49:48.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-04T18:04:25.000Z (almost 3 years ago)
- Last Synced: 2024-10-25T18:55:06.098Z (2 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iter_tar
Python library to iterate through a tar file## Example
```python
with open('archive.tar', 'rb') as f:
found = None
for entry in iter_tar(f):
if str(entry.name) == 'sentinel.txt':
found = entry
if found is None:
raise KeyError('sentinel.txt')
with found.name.open(mode='wb') as out:
shutil.copyfileobj(found, out)
out.seek(found.size)
out.truncate()
found.name.chmod(found.mode)
os.chown(found.name, found.uid, found.gid)
```