This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from forkdelta/v2
V2
- Loading branch information
Showing
1,838 changed files
with
169,928 additions
and
54,278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.6-alpine | ||
FROM python:3.8-alpine3.11 | ||
|
||
WORKDIR /usr/src/scripts | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from glob import glob | ||
from itertools import groupby | ||
import re | ||
|
||
from entry_io import (read_entry, write_token_entry) | ||
|
||
OVERRIDES = {"Technical Documentation": "technical_doc"} | ||
|
||
|
||
def update_key_format(k): | ||
human_k = re.sub(r' (\d+)$', '', k) | ||
return OVERRIDES.get(human_k, human_k.lower().replace(' ', '_')) | ||
|
||
|
||
def convert_links(links): | ||
link_tuples = [(update_key_format(k), v) for (k, v) in links.items()] | ||
return { | ||
group_name: [value for (_, value) in name_value_tuples] | ||
for (group_name, name_value_tuples | ||
) in groupby(sorted(link_tuples), key=lambda e: e[0]) | ||
} | ||
|
||
|
||
entry_files = sorted(glob("tokens/0x*.yaml")) | ||
for entry in (read_entry(fn) for fn in entry_files): | ||
address = entry.pop("address") | ||
entry.update({ | ||
"markets": [], | ||
"links": convert_links(entry['links']), | ||
}) | ||
if "tags" in entry: | ||
del entry["tags"] | ||
del entry["website_slug"] | ||
write_token_entry(address, entry) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import yaml | ||
|
||
YAML_WIDTH = 100 | ||
YAML_INDENT = 2 | ||
|
||
|
||
def read_entry(fn): | ||
with open(fn) as infile: | ||
return yaml.safe_load(infile) | ||
|
||
|
||
def write_token_entry(address, listing): | ||
with open("tokens/{}.yaml".format(address), "w") as outfile: | ||
outfile.write( | ||
yaml.dump( | ||
dict( | ||
address=address, | ||
**{k: v | ||
for (k, v) in listing.items() if v}), | ||
explicit_start=True, | ||
width=YAML_WIDTH, | ||
indent=YAML_INDENT, | ||
default_flow_style=False, | ||
allow_unicode=True)) | ||
|
||
|
||
def update_token_entry(address, partial_update): | ||
old_listing = read_entry("tokens/{}.yaml".format(address)) | ||
old_listing.update(partial_update) | ||
del old_listing["address"] | ||
write_token_entry(address, old_listing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.