aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-07-20 15:07:47 +0200
committerMatěj Cepl <mcepl@cepl.eu>2022-07-26 09:19:23 +0200
commite19073995f0073e5b05250e88399e5b20a60f4dc (patch)
treed234e7473bac9fd13a75bc763f1c59cc34ff1c4a
parentbfe8fe85e86fbe01ef29cebecbcc9d646e171724 (diff)
downloadosc-fast-export-e19073995f0073e5b05250e88399e5b20a60f4dc.tar.gz
A bit more cleanup (typing et al.)
-rwxr-xr-xosc_fast_export.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/osc_fast_export.py b/osc_fast_export.py
index 3b7c727..f07775a 100755
--- a/osc_fast_export.py
+++ b/osc_fast_export.py
@@ -4,11 +4,13 @@
import collections
import configparser
from datetime import datetime
+import pathlib
import subprocess
+from typing import List
import xml.etree.ElementTree as ET
-authorsfile = "authorsfile.txt"
+authorsfile = pathlib.PurePath(".git", "authorsfile.txt")
# For reading section-less config files
# https://stackoverflow.com/a/2819788/164233
@@ -18,8 +20,10 @@ def FakeSecHead(fp):
config = configparser.ConfigParser()
-config.read_file(FakeSecHead(open(authorsfile)))
-authors = dict(config.items("asection"))
+authors = {}
+if authorsfile.exists():
+ config.read_file(FakeSecHead(open(authorsfile)))
+ authors = dict(config.items("asection"))
class LogEntry(
@@ -32,7 +36,7 @@ class LogEntry(
)
-def osc_log():
+def osc_log() -> List[LogEntry]:
try:
log_str = subprocess.run(
["osc", "log", "--xml"], check=True, text=True, stdout=subprocess.PIPE
@@ -54,11 +58,11 @@ def osc_log():
return log_list
-def export_data(dt):
+def export_data(dt: str) -> str:
return f"data {len(dt)}\n{dt}"
-def print_export(entry):
+def print_export(entry: LogEntry) -> int:
mark = entry.rev
author = authors.get(entry.author, "<none>")
date = int(datetime.timestamp(entry.date))
@@ -69,6 +73,7 @@ def print_export(entry):
print(export_data(entry.msg))
if last_mark:
print(f"from :{last_mark}")
+ # The following is dummy, needs to be replaced by actual content of each commit.
print("deleteall")
print("M 644 inline tralala")
print(export_data("tralalala"))