Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..206af2c
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,12 @@
+[tool.black]
+target-version = ['py37']
+
+[tool.isort]
+multi_line_output = 3
+include_trailing_comma = true
+force_grid_wrap = 0
+use_parentheses = true
+ensure_newline_before_comments = true
+line_length = 88
+force_sort_within_sections = true
+
diff --git a/revisions_sort.py b/revisions_sort.py
index 2eb647d..a4905eb 100755
--- a/revisions_sort.py
+++ b/revisions_sort.py
@@ -1,47 +1,47 @@
#!/usr/bin/env python
+from datetime import datetime
import gzip
import sys
-from datetime import datetime
from swh.model.hashutil import hash_to_bytes, hash_to_hex
if __name__ == "__main__":
if len(sys.argv) != 3:
print("usage: revisions_sort <infile> <outfile>")
exit(-1)
infilename = sys.argv[1]
outfilename = sys.argv[2]
with gzip.open(infilename, "rt") as infile:
revisions = []
sort = False
for idx, line in enumerate(infile.readlines(), start=1):
if line.strip():
splitted = line.split(",")
revision = hash_to_bytes(splitted[0])
date = datetime.fromisoformat(splitted[1])
root = hash_to_bytes(splitted[2])
assert date is not None
if revisions:
last = revisions[-1]
if date < last[1]:
print("Out of order", last, f"({revision},{date},{root})")
sort = True
revisions.append((revision, date, root))
if sort:
revisions = sorted(revisions, key=lambda rev: rev[1])
date = None
with gzip.open(outfilename, "wt") as outfile:
for rev in revisions:
assert date == None or date <= rev[1]
date = rev[1]
outfile.write(
f"{hash_to_hex(rev[0])},{rev[1]},{hash_to_hex(rev[2])}\n"
)

File Metadata

Mime Type
text/x-diff
Expires
Jun 4 2025, 7:53 PM (13 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3248281

Event Timeline