From 62961080006ab8ceef48dfce2700f19f713e3f1d Mon Sep 17 00:00:00 2001 From: tom5079 Date: Mon, 5 Oct 2020 19:06:41 +0900 Subject: [PATCH] Added update script --- ko.json | 0 scripts/tags.py | 2 -- scripts/update.py | 17 +++++++++++++++++ scripts/update.sh | 13 +++++++++++++ template.json | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) delete mode 100644 ko.json diff --git a/ko.json b/ko.json deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/tags.py b/scripts/tags.py index 5d9d626e..f3e167ea 100644 --- a/scripts/tags.py +++ b/scripts/tags.py @@ -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): diff --git a/scripts/update.py b/scripts/update.py index e69de29b..4c598edf 100644 --- a/scripts/update.py +++ b/scripts/update.py @@ -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) \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index e69de29b..21d6401a 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -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 \ No newline at end of file diff --git a/template.json b/template.json index e69de29b..9e26dfee 100644 --- a/template.json +++ b/template.json @@ -0,0 +1 @@ +{} \ No newline at end of file