Added update script

This commit is contained in:
tom5079
2020-10-05 19:06:41 +09:00
parent 97e060fa0c
commit 6296108000
5 changed files with 31 additions and 2 deletions

View File

View File

@@ -21,8 +21,6 @@ for index in indices:
count = int(count_regex.match(item.text).group(1))
tags[tag] = count
break
tag_regex = re.compile(r".+:(.+)$")
def clean(tag):

View File

@@ -0,0 +1,17 @@
import json
import sys
tags = {tag: u'' for tag in json.loads(''.join(sys.stdin.readlines()))}
try:
with open(sys.argv[1], encoding='utf-8') as f:
lang = json.load(f)
except:
lang = dict()
for tag in tags:
if tag in lang and lang[tag]:
tags[tag] = lang[tag]
with open(sys.argv[1], 'w', encoding='utf-8') as f:
json.dump(tags, f, indent=4, ensure_ascii=False)

View File

@@ -0,0 +1,13 @@
#!/bin/bash
TAGS_PYTHON=/home/tom5079/.virtualenvs/tags/bin/python
TAGS_FOLDER=/mnt/d/Workspace/Pupil-gh-pages
$TAGS_PYTHON -m pip install -r $TAGS_FOLDER/scripts/requirements.txt > NUL
tags=$($TAGS_PYTHON $TAGS_FOLDER/scripts/tags.py)
for file in "$(ls $TAGS_FOLDER/*.json)"
do
echo "$tags" | $TAGS_PYTHON $TAGS_FOLDER/scripts/update.py $file
done

View File

@@ -0,0 +1 @@
{}