-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
66 lines (52 loc) · 1.81 KB
/
start.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
57
58
59
60
61
62
63
64
65
66
import jsonpickle
from typing import Dict, List
from config import Config
from tail import Tail, TailDetails
from tail_database import TailDatabase
if Config.output_directory is None:
raise Exception("TAILDB_EXPORTER_OUTPUT_DIR must be set")
search_index: Dict[str, List[str]] = {}
hashes: Dict[str, TailDetails] = {}
tails: List[Tail] = []
tail_database = TailDatabase()
for tail in tail_database.tails():
tail_reveal = tail_database.tail_reveal(tail["eveCoinId"])
nft_uri = tail_database.nft_uri(tail["launcherId"])
website_url = tail.get("website_url")
twitter_url = tail.get("twitter_url")
discord_url = tail.get("discord_url")
tail = Tail(
tail["hash"],
tail["name"],
tail["code"],
tail["description"],
tail["category"],
tail["launcherId"],
tail["eveCoinId"],
tail_reveal,
nft_uri,
website_url,
twitter_url,
discord_url,
)
tails.append(tail)
hashes[tail.hash] = TailDetails(tail.name, tail.code, tail.nft_uri)
search_index[tail.code.lower()] = [tail.hash]
for word in tail.name.split(" "):
word = word.lower()
if search_index.get(word) is None:
search_index[word] = [tail.hash]
else:
search_index[word].append(tail.hash)
tail_json = jsonpickle.encode(tail, unpicklable=False)
with open(Config.output_directory + f"/{tail.hash}.json", 'w+') as f:
f.write(tail_json)
search_index_json = jsonpickle.encode({
"search_index": search_index,
"hashes": hashes
}, unpicklable=False)
tails_json = jsonpickle.encode(tails, unpicklable=False)
with open(Config.output_directory + f"/search_index.json", 'w+') as f:
f.write(search_index_json)
with open(Config.output_directory + f"/tails.json", 'w+') as f:
f.write(tails_json)