Skip to content

Commit e900c21

Browse files
committed
Fix python linting issues
(cherry picked from commit 5e8978c)
1 parent cf42228 commit e900c21

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

.github/jobs/jsontogha.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@
33
import time
44
import hashlib
55

6-
storage1 ={}
6+
storage1 = {}
77
storage2 = {}
88

9+
910
def cleanHash(toHash):
1011
return hashlib.sha224(toHash).hexdigest()
1112

12-
def sec_start(job,header):
13+
14+
def sec_start(job, header):
1315
print('section_start\r\033[0K'+header)
1416

17+
1518
def sec_end(job):
1619
print('section_end\r\033[0K')
1720

18-
with open(sys.argv[1],'r') as f:
19-
data = json.load(f, encoding='utf-8')
21+
with open(sys.argv[1], 'r') as f:
22+
data = json.load(f)
2023
for message in data['messages']:
2124
mtyp = message['type'].encode('utf-8', 'ignore')
2225
murl = message['url'].encode('utf-8', 'ignore')
2326
mmes = message['message'].encode('utf-8', 'ignore')
2427
if mtyp not in storage1.keys():
25-
storage1[mtyp] = {"messages":{}, "cnt":0}
26-
storage2[mtyp] = {"urls":{}, "cnt":0}
28+
storage1[mtyp] = {"messages": {}, "cnt": 0}
29+
storage2[mtyp] = {"urls": {}, "cnt": 0}
2730
if mmes not in storage1[mtyp]["messages"].keys():
28-
storage1[mtyp]["messages"][mmes] = {"urls":{}, "cnt":0}
31+
storage1[mtyp]["messages"][mmes] = {"urls": {}, "cnt": 0}
2932
if murl not in storage2[mtyp]["urls"].keys():
30-
storage2[mtyp]["urls"][murl] = {"messages":{}, "cnt":0}
33+
storage2[mtyp]["urls"][murl] = {"messages": {}, "cnt": 0}
3134
if murl not in storage1[mtyp]["messages"][mmes]["urls"].keys():
3235
storage1[mtyp]["messages"][mmes]["urls"][murl] = 0
3336
if mmes not in storage2[mtyp]["urls"][murl]["messages"].keys():
@@ -38,18 +41,18 @@ def sec_end(job):
3841
storage2[mtyp]["urls"][murl]["messages"][mmes] += 1
3942
storage2[mtyp]["urls"][murl]["cnt"] += 1
4043
storage2[mtyp]["cnt"] += 1
41-
# Stats
42-
for key,value in sorted(storage1.items(), key=lambda x:x[1]['cnt']):
43-
print("Type: {}, Totalfound: {}".format(key, value["cnt"]))
44-
for key2,value2 in sorted(storage1[key]["messages"].items(), key=lambda x:x[1]['cnt'], reverse=True):
44+
45+
for key, value in sorted(storage1.items(), key=lambda x: x[1]['cnt']):
46+
print("Type: {}, Totalfound: {}".format(key, value["cnt"]))
47+
for key2, value2 in sorted(storage1[key]["messages"].items(), key=lambda x: x[1]['cnt'], reverse=True):
4548
sec_start(key+key2, key2)
46-
print("[{}] [{}%] Message: {}".format(key, round(100*value2["cnt"]/value["cnt"],2), key2))
47-
for key3,value3 in sorted(storage1[key]["messages"][key2]["urls"].items(), key=lambda x:x[1], reverse=True):
48-
print("[{}%] URL: {}".format(round(100*value3/value2["cnt"],2), key3))
49+
print("[{}] [{}%] Message: {}".format(key, round(100*value2["cnt"]/value["cnt"], 2), key2))
50+
for key3, value3 in sorted(storage1[key]["messages"][key2]["urls"].items(), key=lambda x: x[1], reverse=True):
51+
print("[{}%] URL: {}".format(round(100*value3/value2["cnt"], 2), key3))
4952
sec_end(key+key2)
50-
for key2,value2 in sorted(storage2[key]["urls"].items(), key=lambda x:x[1]['cnt'], reverse=True):
53+
for key2, value2 in sorted(storage2[key]["urls"].items(), key=lambda x: x[1]['cnt'], reverse=True):
5154
sec_start(key+key2, key2)
52-
print("[{}] [{}%] URL: {}".format(key, round(100*value2["cnt"]/value["cnt"],2), key2))
53-
for key3,value3 in sorted(storage2[key]["urls"][key2]["messages"].items(), key=lambda x:x[1], reverse=True):
54-
print("[{}%] Message: {}".format(round(100*value3/value2["cnt"],2), key3))
55+
print("[{}] [{}%] URL: {}".format(key, round(100*value2["cnt"]/value["cnt"], 2), key2))
56+
for key3, value3 in sorted(storage2[key]["urls"][key2]["messages"].items(), key=lambda x: x[1], reverse=True):
57+
print("[{}%] Message: {}".format(round(100*value3/value2["cnt"], 2), key3))
5558
sec_end(key+key2)

0 commit comments

Comments
 (0)