OLD | NEW |
(Empty) | |
| 1 """Writes a res_index.txt file listing all locales (resources) that |
| 2 are included. This matches a half dozen "echo" blocks in the |
| 3 Makefiles.""" |
| 4 |
| 5 from __future__ import print_function |
| 6 |
| 7 import argparse |
| 8 import os |
| 9 |
| 10 def change_ext(path, new_ext): |
| 11 return os.path.splitext(path)[0] + new_ext |
| 12 |
| 13 def main(): |
| 14 parser = argparse.ArgumentParser( |
| 15 description=("Generates a resindex.txt file to be compiled by icu.")) |
| 16 |
| 17 parser.add_argument("--outfile", |
| 18 required=True, |
| 19 help="File that will contain the ICU resource text.") |
| 20 |
| 21 parser.add_argument("--cldr-version", |
| 22 help="The CLDR version. Optional") |
| 23 |
| 24 parser.add_argument("files", |
| 25 nargs='*', |
| 26 help=("Files to be included in the list. " + |
| 27 "Can include paths (that will be ignored)")) |
| 28 |
| 29 args = parser.parse_args() |
| 30 |
| 31 with open(args.outfile, "w") as out: |
| 32 out.write("// Warning this file is automatically generated\n") |
| 33 out.write("res_index:table(nofallback) {\n") |
| 34 if args.cldr_version: |
| 35 out.write(" CLDRVersion { \"%s\" }\n" % args.cldr_version) |
| 36 out.write(" InstalledLocales {\n") |
| 37 for filename in args.files: |
| 38 out.write(" %s {\"\"}\n" % |
| 39 change_ext(os.path.basename(filename), "")) |
| 40 out.write(" }\n") |
| 41 out.write("}\n") |
| 42 |
| 43 if __name__ == "__main__": |
| 44 main() |
OLD | NEW |