Make comments differentiate files

Closes #12
This commit is contained in:
Matej Focko 2020-05-26 14:17:11 +02:00
parent a0eaafc12e
commit 102ef3e6ec
Signed by: mfocko
GPG key ID: 299B916A55682021

View file

@ -19,13 +19,18 @@ class Comments(BaseCommand):
for comment in comments:
author = comment["author"]["username"], comment["author"]["name"]
if author not in result:
result[author] = list()
result[author] = dict()
result[author].append(comment)
file_path = comment["position"]["new_path"] if "position" in comment else None
if file_path not in result[author]:
result[author][file_path] = list()
result[author][file_path].append(comment)
# sort by lines
for author in result:
result[author].sort(key=lambda comment:
for file_path in result[author]:
result[author][file_path].sort(key=lambda comment:
comment["position"]["new_line"] if "position" in comment
else math.inf)
@ -40,7 +45,10 @@ class Comments(BaseCommand):
header = f"***** {name} ({login}) *****".center(40, "*").center(80)
print(header)
for comment in comments[author]:
for file_path in comments[author]:
if file_path is not None:
print(f"# `{file_path.split('/')[-1]}`")
for comment in comments[author][file_path]:
if comment["system"]:
continue