Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
```