Welcome to mirror list, hosted at ThFree Co, Russian Federation.

languages_dir.py « tts « sound - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e1fb1a75bd3f00c4cc755da817642cb90037f9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python

from __future__ import print_function
from optparse import OptionParser

import os


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():
  langs_name, json_dir_name = parse_args()

  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)


if __name__ == "__main__":
  run()