File indexing completed on 2021-12-21 14:33:23

0001 #!/usr/bin/python3
0002 
0003 import os
0004 import sys
0005 import subprocess
0006 import json
0007 
0008 if len(sys.argv) == 2:
0009     l10n_path = sys.argv[1]
0010 else:
0011     sys.exit("Usage: %s <l10n_path>" % sys.argv[0])
0012 
0013 if not subprocess.call(["which", "po4a-translate"],
0014                        stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
0015     sys.exit("Error: po4a is not available.")
0016 
0017 
0018 def get_subdirs(root):
0019     for fname in os.listdir(root):
0020         fpath = os.path.join(root, fname)
0021         if os.path.isdir(fpath):
0022             yield fname, fpath
0023 
0024 directory = {}
0025 
0026 for locale_name, locale_path in get_subdirs(l10n_path):
0027     directory[locale_name] = {
0028         'slides' : [slide for slide in os.listdir(locale_path)],
0029         'media' : []
0030     }
0031     directory[locale_name]['slides'].sort()
0032 
0033 content = json.dumps(directory)
0034 sys.stdout.write('ubiquitySlideshowDirectoryCb(')
0035 sys.stdout.write(content)
0036 sys.stdout.write(');\n')