forked from Polkadex-Substrate/Polkadex-Open-Beta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
106 lines (84 loc) · 2.63 KB
/
Copy pathscript.py
File metadata and controls
106 lines (84 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import csv
import copy
import re
import sys
from substrateinterface import SubstrateInterface
def update_csv_file():
description = sys.argv[1]
issue_rating = int(sys.argv[2])
onchain_id = ""
onchain_address = ""
print(description)
for x in description.splitlines():
if "onchainaddress" in x:
onchain_address = x.split(":")[1]
substrate = SubstrateInterface(
url="wss://mainnet.polkadex.trade"
)
try:
result = substrate.query(
module='Identity',
storage_function='IdentityOf',
params=[onchain_address]
)
onchain_id = result.value['info']['display']['Raw']
except:
print("An exception occured")
file = open("beta.csv")
csvreader = csv.reader(file)
header = next(csvreader)
print(header)
rows = []
for row in csvreader:
rows.append(row)
print(rows)
if len(rows) == 0:
print("New CSV")
rows.append([onchain_id,"0","0","0","0"])
if issue_rating == 3:
rows[0][1] = int(rows[0][1]) + 1
rows[0][4] = 1
elif issue_rating == 2:
rows[0][2] = int(rows[0][2]) + 1
rows[0][4] = 1
elif issue_rating == 1:
rows[0][3] = int(rows[0][3]) + 1
rows[0][4] = 1
filename = 'beta.csv'
with open(filename, 'w', newline="") as file:
csvwriter = csv.writer(file)
csvwriter.writerow(header)
csvwriter.writerows(rows)
return
flag = True
for x in rows:
if x[0] == onchain_id:
if issue_rating == 3:
x[1] = int(x[1]) + 1
elif issue_rating == 2:
x[2] = int(x[2]) + 1
elif issue_rating == 1:
x[3] = int(x[3]) + 1
flag = False
# If first time
if flag == True:
new_tester = copy.copy(rows[0])
new_tester[0] = onchain_id
new_tester[1] = 0
new_tester[2] = 0
new_tester[3] = 0
if issue_rating == 3:
new_tester[1] = int(new_tester[1]) + 1
elif issue_rating == 2:
new_tester[2] = int(new_tester[2]) + 1
elif issue_rating == 1:
new_tester[3] = int(new_tester[3]) + 1
rows.append(new_tester)
for x in rows:
x[4] = int(x[1]) + int(x[2]) + int(x[3])
filename = 'beta.csv'
with open(filename, 'w', newline="") as file:
csvwriter = csv.writer(file)
csvwriter.writerow(header)
csvwriter.writerows(rows)
update_csv_file()