diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2015-07-22 09:04:21 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:57:18 +0300 |
commit | 6d8fdf14b7a42faa77449114824f44276fdd5b13 (patch) | |
tree | 7612236a5dd5f41223c3cbbfc4b80b28831b5416 /sound | |
parent | 04016db2b6d6cf70d65a19fd3b7bf7578e49de20 (diff) |
Python script for generating language directories for twine for conversion to json.
Diffstat (limited to 'sound')
-rwxr-xr-x | sound/tts/languages_dir.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sound/tts/languages_dir.py b/sound/tts/languages_dir.py new file mode 100755 index 0000000000..60abd1b71c --- /dev/null +++ b/sound/tts/languages_dir.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +import os + +from optparse import OptionParser + + +def parse_args(): + opt_parser = OptionParser(usage="This tool creates directories for languages for twine." + + "All directory names shall be listed in languages file with space separator.\n" + + "Example: python %prog path_to_language_file.txt path_to_dir_with_json_files", + version="%prog 1.0") + + (options, args) = opt_parser.parse_args() + + if len(args) != 2: + opt_parser.error("Wrong number of arguments.") + return args + + +def run(): + args = parse_args() + + langs_name = args[0] + json_dir_name = args[1] + + print "Creating directories for languages in json." + with open(langs_name, 'r') as langs_file: + for lang in langs_file.read().split(): + new_dir = json_dir_name + lang + '.json' + if not os.path.exists(new_dir): + os.makedirs(new_dir) + + langs_file.close() + + +if __name__ == "__main__": + run() |