-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateindex-id.py
More file actions
146 lines (123 loc) · 6.03 KB
/
createindex-id.py
File metadata and controls
146 lines (123 loc) · 6.03 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import glob
import sys
import os
def clean_string(s):
return s.replace('Cases_on_an_international_conveyance_Japan',
'Cases Int Cnv Japan').replace('United_Arab_Emirates',
'Uni. Arab Emi.').replace('Democratic_Republic_of_the_Congo',
'Demo. Rep. Congo').replace('_', ' ')
if len(sys.argv) != 2:
print(f'{sys.argv[0]}: {sys.argv[0]} <id>')
sys.exit(0)
try:
g_id = int(sys.argv[1])
except:
print(f'id must be an integer [0,8]')
sys.exit(0)
if g_id < 0 or g_id > 20:
print(f'processing id must be [0,8]')
sys.exit(0)
BR_states = ["Sao_Paulo", "Minas_Gerais", "Rio_de_Janeiro", "Bahia",
"Parana", "Rio_Grande_do_Sul", "Pernambuco", "Ceara",
"Para", "Santa_Catarina", "Maranhao", "Goias",
"Amazonas", "Espirito_Santo", "Paraiba", "Rio_Grande_do_Norte",
"Mato_Grosso", "Alagoas", "Piaui", "Distrito_Federal",
"Mato_Grosso_do_Sul", "Sergipe", "Rondonia", "Tocantins",
"Acre", "Amapa", "Roraima"]
W_regions = list()
with open('log/processed.log', 'r') as f:
for line in f.readlines():
region = line.split(',')
W_regions.append(region[0].strip())
W_regions.sort()
# Sorry, it O(n), but...
BR_states.sort()
BR_states.insert(0, 'Brasil')
for i in BR_states:
if i in W_regions:
W_regions.remove(i)
while 'Brasil' in W_regions:
W_regions.remove('Brasil')
f = open('index_id_template.html', 'r')
if g_id < 9:
l = 5 - len(BR_states) % 5
else:
l = 2 - len(BR_states) % 2
for i in range(l):
BR_states.append('Brasil')
str_id = 'EDO' if g_id == 6 else 'SOCNET'
for i in range(37):
line = f.readline()
print(line.replace('Model', f'{str_id} Model'))
if g_id < 9:
for i in range(0, len(BR_states), 5):
name = BR_states[i]
name = name.replace('_', ' ')
print(
f'<tr><td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i]}-{g_id}.html"><img src="web/svg/{BR_states[i]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = BR_states[i+1]
name = name.replace('_', ' ')
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i+1]}-{g_id}.html"><img src="web/svg/{BR_states[i+1]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = BR_states[i+2]
name = name.replace('_', ' ')
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i+2]}-{g_id}.html"><img src="web/svg/{BR_states[i+2]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = BR_states[i+3]
name = name.replace('_', ' ')
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i+3]}-{g_id}.html"><img src="web/svg/{BR_states[i+3]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = BR_states[i+4]
name = name.replace('_', ' ')
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i+4]}-{g_id}.html"><img src="web/svg/{BR_states[i+4]}-{g_id}.svg" width="150" height="150"/></a></td></tr>')
else:
for i in range(0, len(BR_states), 2):
name = BR_states[i]
name = name.replace('_', ' ')
print(
f'<tr><td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i]}-{g_id}.html"><img src="web/svg/{BR_states[i]}-{g_id}.svg" width="375" height="150"/></a></td>')
name = BR_states[i+1]
name = name.replace('_', ' ')
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{BR_states[i+1]}-{g_id}.html"><img src="web/svg/{BR_states[i+1]}-{g_id}.svg" width="375" height="150"/></a></td></tr>')
if g_id < 9:
l = 5 - len(W_regions) % 5
if l != 5:
for i in range(l):
W_regions.append('Brazil')
else:
l = 2 - len(W_regions) % 2
if l != 2:
for i in range(l):
W_regions.append('Brazil')
for i in range(12):
line = f.readline()
print(line)
if g_id < 9:
for i in range(0, len(W_regions), 5):
name = clean_string(W_regions[i])
print(
f'<tr><td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i]}-{g_id}.html"><img src="web/svg/{W_regions[i]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = clean_string(W_regions[i+1])
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i+1]}-{g_id}.html"><img src="web/svg/{W_regions[i+1]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = clean_string(W_regions[i+2])
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i+2]}-{g_id}.html"><img src="web/svg/{W_regions[i+2]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = clean_string(W_regions[i+3])
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i+3]}-{g_id}.html"><img src="web/svg/{W_regions[i+3]}-{g_id}.svg" width="150" height="150"/></a></td>')
name = clean_string(W_regions[i+4])
print(
f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i+4]}-{g_id}.html"><img src="web/svg/{W_regions[i+4]}-{g_id}.svg" width="150" height="150"/></a></td></tr>')
else:
for i in range(0, len(W_regions), 2):
name = clean_string(W_regions[i])
print(
f'<tr><td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i]}-{g_id}.html"><img src="web/svg/{W_regions[i]}-{g_id}.svg" width="375" height="150"/></a></td>')
name = clean_string(W_regions[i+1])
print(f'<td><div class="w3-tiny w3-center">{name}</div><a href="web/report/{W_regions[i+1]}-{g_id}.html"><img src="web/svg/{W_regions[i+1]}-{g_id}.svg" width="375" height="150"/></a></td></tr>')
for i in f.readlines():
print(i)
f.close()