##// END OF EJS Templates
use pathlib.Path in retar.py
rushabh-v -
Show More
@@ -22,14 +22,17 b' import os'
22 22 import gzip
23 23 import io
24 24
25 from pathlib import Path
26
25 27 if len(sys.argv) > 2:
26 28 raise ValueError("Too many arguments")
27 29
28 30
29 31 timestamp = int(os.environ["SOURCE_DATE_EPOCH"])
30 32
33 path = Path(sys.argv[1])
31 34 old_buf = io.BytesIO()
32 with open(sys.argv[1], "rb") as f:
35 with open(path, "rb") as f:
33 36 old_buf.write(f.read())
34 37 old_buf.seek(0)
35 38 old = tarfile.open(fileobj=old_buf, mode="r:gz")
@@ -56,10 +59,10 b' new.close()'
56 59 old.close()
57 60
58 61 buf.seek(0)
59 with open(sys.argv[1], "wb") as f:
62 with open(path, "wb") as f:
60 63 with gzip.GzipFile('', "wb", fileobj=f, mtime=timestamp) as gzf:
61 64 gzf.write(buf.read())
62 65
63 66 # checks the archive is valid.
64 archive = tarfile.open(sys.argv[1])
67 archive = tarfile.open(path)
65 68 names = archive.getnames()
General Comments 0
You need to be logged in to leave comments. Login now