mirror of
https://github.com/Mayccoll/Gogh.git
synced 2023-08-10 21:12:46 +03:00
Add script to replace themes in goth - also fix paths on tools scripts
This commit is contained in:
parent
a00b6ca9fa
commit
a8ef68e2a5
5
.github/workflows/actions.yml
vendored
5
.github/workflows/actions.yml
vendored
@ -54,6 +54,11 @@ jobs:
|
|||||||
python3 tools/generateShFiles.py
|
python3 tools/generateShFiles.py
|
||||||
echo 🏅
|
echo 🏅
|
||||||
|
|
||||||
|
- name: update themes in gogh file
|
||||||
|
run: |
|
||||||
|
python3 tools/updateThemes.py
|
||||||
|
echo 🏅
|
||||||
|
|
||||||
- name: Git commit
|
- name: Git commit
|
||||||
run: |
|
run: |
|
||||||
git config user.name github-actions[bot]
|
git config user.name github-actions[bot]
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
import yaml
|
import yaml
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
source_path = "./themes-yml"
|
source_path = "./themes"
|
||||||
dest_path = "./data/themes.json"
|
dest_path = "./data/themes.json"
|
||||||
themes = []
|
themes = []
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
folder_path = "./themes-yml"
|
folder_path = "./themes"
|
||||||
dest_path = './installs'
|
dest_path = './installs'
|
||||||
themes = []
|
themes = []
|
||||||
|
|
||||||
|
32
tools/updateThemes.py
Normal file
32
tools/updateThemes.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import json
|
||||||
|
import re
|
||||||
|
from unidecode import unidecode
|
||||||
|
|
||||||
|
input_file = 'data/themes.json'
|
||||||
|
output_file = 'gogh.sh'
|
||||||
|
|
||||||
|
start_text = "declare -a THEMES=("
|
||||||
|
end_text = ")"
|
||||||
|
|
||||||
|
with open(input_file, "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
theme_names = [re.sub(r'[^a-zA-Z0-9\s]+', '-', unidecode(theme["name"]).lower().replace(' ', '-')).rstrip('-') for theme in data["themes"]]
|
||||||
|
themes = sorted(list(set([f"{name}.sh" for name in theme_names])))
|
||||||
|
|
||||||
|
with open(output_file, "r") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
|
||||||
|
with open(output_file, "w") as f:
|
||||||
|
found_start = False
|
||||||
|
for line in lines:
|
||||||
|
if start_text in line:
|
||||||
|
found_start = True
|
||||||
|
f.write(line)
|
||||||
|
for theme in themes:
|
||||||
|
f.write(f" '{theme}'\n")
|
||||||
|
elif end_text in line:
|
||||||
|
found_start = False
|
||||||
|
f.write(line)
|
||||||
|
elif not found_start:
|
||||||
|
f.write(line)
|
Loading…
Reference in New Issue
Block a user