Skip to content

Commit

Permalink
Merge pull request #708 from ulyssear/features/command-generate-missi…
Browse files Browse the repository at this point in the history
…ng-templates

Added command to generate all missing templates
  • Loading branch information
geekygirlsarah authored Nov 28, 2023
2 parents c46c2db + 68bab56 commit d9d6a3b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions web/management/commands/generate_missing_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.core.management.base import BaseCommand

from web.models import Language, MetaInfo

import os


class Command(BaseCommand):
help = 'Generate missing language thesaurus files to be filled out'

def handle(self, *args, **options):
meta_info = MetaInfo()
languages = meta_info.languages
structures = meta_info.structures

for language in languages:
versions = Language(language, languages[language]).versions()
for version in versions:
for structure in structures:
file_path = os.path.join(
'web',
'thesauruses',
language,
version,
structure + '.json'
)
if not os.path.exists(file_path):
os.system(f'python manage.py generate_template "{language}" "{structure}" --language-version="{version}"')

0 comments on commit d9d6a3b

Please sign in to comment.