-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from ulyssear/features/command-generate-missi…
…ng-templates Added command to generate all missing templates
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"') |