Skip to content

Commit

Permalink
PB-227: Rename and restructure code
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJoss committed Aug 26, 2024
1 parent ad1478a commit 3e5073c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/helpers/description.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import json
import os

from app.settings import JSON_FOLDER
from app.settings import DESCRIPTION_FOLDER


def get_icon_set_description(icon_set=''):
path = os.path.abspath(os.path.join(JSON_FOLDER, icon_set + '-dictionary.json'))
path = os.path.abspath(os.path.join(DESCRIPTION_FOLDER, icon_set + '-dictionary.json'))
if not os.path.isfile(path):
return None

with open(path, encoding='utf-8') as f:
df = json.load(f)
icon_set_descriptions = json.load(f)

return df
return icon_set_descriptions


def get_icon_description(icon_name='', icon_set=''):
path = os.path.abspath(os.path.join(JSON_FOLDER, icon_set + '-dictionary.json'))
path = os.path.abspath(os.path.join(DESCRIPTION_FOLDER, icon_set + '-dictionary.json'))
if not os.path.isfile(path):
return False

Expand Down
4 changes: 3 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
load_dotenv(ENV_FILE, override=True, verbose=True)

IMAGE_FOLDER = os.path.abspath(os.path.join(os.path.dirname(__file__), '../static/images/'))
JSON_FOLDER = os.path.abspath(os.path.join(os.path.dirname(__file__), '../json/'))
DESCRIPTION_FOLDER = os.path.abspath(
os.path.join(os.path.dirname(__file__), '../metadata/description/')
)

COLORABLE_ICON_SETS = ['default']
DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/generate_babs_dic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate_translation_file(args):

def main():
# example command:
# python3 generate_babs_dic.py --input=../../tmp/Namenliste.xlsx --output=../json/babs
# python3 generate_babs_dic.py --input=../../tmp/babs.xlsx --output=../metadata/description/babs
# (do not specify filetype for output since it creates a file for every language)
parser = argparse.ArgumentParser(description='Create json translation file from excel file ')
parser.add_argument('--input', action="store", dest='input', default=None)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_json.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import os

from app.settings import JSON_FOLDER
from app.settings import DESCRIPTION_FOLDER
from tests.unit_tests.base_test import ServiceIconsUnitTests


Expand All @@ -16,10 +16,10 @@ def validate_json(json_file):
class IconsTests(ServiceIconsUnitTests):

def test_json(self):
path = os.path.abspath(os.path.join(JSON_FOLDER, 'babs2_dictionary.json'))
path = os.path.abspath(os.path.join(DESCRIPTION_FOLDER, 'babs2_dictionary.json'))
self.assertTrue(os.path.exists(path), "babs2 json file doesn't exist")

for root, dirs, files in os.walk(os.path.join(JSON_FOLDER)):
for root, dirs, files in os.walk(os.path.join(DESCRIPTION_FOLDER)):
for name in files:
p = os.path.join(root, name)
with open(p, encoding='utf-8') as f:
Expand Down

0 comments on commit 3e5073c

Please sign in to comment.