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