Skip to content

Commit

Permalink
Fix python linting issues
Browse files Browse the repository at this point in the history
(cherry picked from commit 5e8978c)
  • Loading branch information
vmcj committed Dec 9, 2024
1 parent cf42228 commit e900c21
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions .github/jobs/jsontogha.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,34 @@
import time
import hashlib

storage1 ={}
storage1 = {}
storage2 = {}


def cleanHash(toHash):
return hashlib.sha224(toHash).hexdigest()

def sec_start(job,header):

def sec_start(job, header):
print('section_start\r\033[0K'+header)


def sec_end(job):
print('section_end\r\033[0K')

with open(sys.argv[1],'r') as f:
data = json.load(f, encoding='utf-8')
with open(sys.argv[1], 'r') as f:
data = json.load(f)
for message in data['messages']:
mtyp = message['type'].encode('utf-8', 'ignore')
murl = message['url'].encode('utf-8', 'ignore')
mmes = message['message'].encode('utf-8', 'ignore')
if mtyp not in storage1.keys():
storage1[mtyp] = {"messages":{}, "cnt":0}
storage2[mtyp] = {"urls":{}, "cnt":0}
storage1[mtyp] = {"messages": {}, "cnt": 0}
storage2[mtyp] = {"urls": {}, "cnt": 0}
if mmes not in storage1[mtyp]["messages"].keys():
storage1[mtyp]["messages"][mmes] = {"urls":{}, "cnt":0}
storage1[mtyp]["messages"][mmes] = {"urls": {}, "cnt": 0}
if murl not in storage2[mtyp]["urls"].keys():
storage2[mtyp]["urls"][murl] = {"messages":{}, "cnt":0}
storage2[mtyp]["urls"][murl] = {"messages": {}, "cnt": 0}
if murl not in storage1[mtyp]["messages"][mmes]["urls"].keys():
storage1[mtyp]["messages"][mmes]["urls"][murl] = 0
if mmes not in storage2[mtyp]["urls"][murl]["messages"].keys():
Expand All @@ -38,18 +41,18 @@ def sec_end(job):
storage2[mtyp]["urls"][murl]["messages"][mmes] += 1
storage2[mtyp]["urls"][murl]["cnt"] += 1
storage2[mtyp]["cnt"] += 1
# Stats
for key,value in sorted(storage1.items(), key=lambda x:x[1]['cnt']):
print("Type: {}, Totalfound: {}".format(key, value["cnt"]))
for key2,value2 in sorted(storage1[key]["messages"].items(), key=lambda x:x[1]['cnt'], reverse=True):

for key, value in sorted(storage1.items(), key=lambda x: x[1]['cnt']):
print("Type: {}, Totalfound: {}".format(key, value["cnt"]))
for key2, value2 in sorted(storage1[key]["messages"].items(), key=lambda x: x[1]['cnt'], reverse=True):
sec_start(key+key2, key2)
print("[{}] [{}%] Message: {}".format(key, round(100*value2["cnt"]/value["cnt"],2), key2))
for key3,value3 in sorted(storage1[key]["messages"][key2]["urls"].items(), key=lambda x:x[1], reverse=True):
print("[{}%] URL: {}".format(round(100*value3/value2["cnt"],2), key3))
print("[{}] [{}%] Message: {}".format(key, round(100*value2["cnt"]/value["cnt"], 2), key2))
for key3, value3 in sorted(storage1[key]["messages"][key2]["urls"].items(), key=lambda x: x[1], reverse=True):
print("[{}%] URL: {}".format(round(100*value3/value2["cnt"], 2), key3))
sec_end(key+key2)
for key2,value2 in sorted(storage2[key]["urls"].items(), key=lambda x:x[1]['cnt'], reverse=True):
for key2, value2 in sorted(storage2[key]["urls"].items(), key=lambda x: x[1]['cnt'], reverse=True):
sec_start(key+key2, key2)
print("[{}] [{}%] URL: {}".format(key, round(100*value2["cnt"]/value["cnt"],2), key2))
for key3,value3 in sorted(storage2[key]["urls"][key2]["messages"].items(), key=lambda x:x[1], reverse=True):
print("[{}%] Message: {}".format(round(100*value3/value2["cnt"],2), key3))
print("[{}] [{}%] URL: {}".format(key, round(100*value2["cnt"]/value["cnt"], 2), key2))
for key3, value3 in sorted(storage2[key]["urls"][key2]["messages"].items(), key=lambda x: x[1], reverse=True):
print("[{}%] Message: {}".format(round(100*value3/value2["cnt"], 2), key3))
sec_end(key+key2)

0 comments on commit e900c21

Please sign in to comment.