-
Notifications
You must be signed in to change notification settings - Fork 0
/
timestamper.py
39 lines (32 loc) · 1.08 KB
/
timestamper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: WTFPL
import glob
import csv
from pathlib import Path
from datetime import datetime
import os
things = {}
recheck_all_timestamps = True
with open("timestamps.csv", newline="", encoding="utf-8") as f:
cr = csv.reader(f)
for line in cr:
if line[0] == "sha1":
continue
things[line[0]] = (line[1], line[2])
for filename in glob.iglob("../hashed/*.bsp"):
"""
A = os.path.getmtime(filename)
B = os.path.getmtime(filename + ".bz2")
if A != B:
print("updating "+filename+".bz2")
os.utime(filename + ".bz2", (A, A))
"""
hash = Path(filename).stem
if not hash in things or recheck_all_timestamps:
things[hash] = (datetime.utcfromtimestamp(os.path.getmtime(filename)), datetime.utcfromtimestamp(os.path.getctime(filename)))
with open("timestamps.csv", "w", newline="", encoding="utf-8") as csvfile:
mycsv = csv.writer(csvfile)
mycsv.writerow(["sha1","mod","create"])
xxx = dict(sorted(things.items()))
for k,v in xxx.items():
mycsv.writerow([k, v[0], v[1]])
#print(things)