-
Notifications
You must be signed in to change notification settings - Fork 0
/
swapLogos.py
56 lines (45 loc) · 1.72 KB
/
swapLogos.py
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
#!/usr/bin/python3
import csv
import json
import pandas
import shutil
import os
from git import Repo
OLD_TOKEN_MAP = 'current_mapping_libre.csv'
TOKEN_MAP = 'penultimate.csv'
LOGOS_IN_DIR = 'Logos'
LOGOS_OUT_DIR = 'avalanche-tokens'
#HOSTED_URL = 'https://raw.githubusercontent.com/ava-labs/bridge-tokens/main/'
def read_logos():
token_map = pandas.read_csv(TOKEN_MAP)
#print(token_map.loc[2:5, ["Avalanche Token Address", "Ethereum Token Address"]])
return token_map
def read_old_logos():
token_map = pandas.read_csv(OLD_TOKEN_MAP)
#print(token_map.loc[2:5, ["Avalanche Token Address", "Ethereum Token Address"]])
return token_map
def swap_logos(token_map, old_token_map):
for _, row in token_map.iterrows():
old_row = old_token_map[old_token_map["Avalanche Token Symbol"] == row['Avalanche Token Symbol']]
if len(old_row.index) == 0:
print("No token for ", row['Avalanche Token Symbol'])
elif len(old_row.index) > 1:
print("Collision for ", row['Avalanche Token Symbol'])
else:
ava_address = row['Avalanche Token Address']
old_ava_address = old_row.iloc[0]['Avalanche Token Address']
old_out_dir = LOGOS_OUT_DIR + '/' + old_ava_address
out_dir = LOGOS_OUT_DIR + '/' + ava_address
#old_logo = old_out_dir + '/logo.png'
#new_logo = out_dir + '/logo.png'
#os.mkdir(out_dir)
try:
shutil.move(old_out_dir, out_dir)
except:
print("Couldn't rename ", old_out_dir, out_dir)
def main():
token_map = read_logos()
old_token_map = read_old_logos()
swap_logos(token_map, old_token_map)
if __name__ == '__main__':
main()