~chromium-team/chromium-browser/translations-pump

« back to all changes in this revision

Viewing changes to process-and-export

  • Committer: Chad Miller
  • Date: 2013-08-16 14:10:56 UTC
  • Revision ID: chad.miller@canonical.com-20130816141056-v51xndsustwcjg6i
Fix exporting gettext placeholders.

Move testing to top of main run function.

Make getting upstream sources a seperate step than running the exporter.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    "ash/resources/ash_resources.grd": None,
56
56
    "ash/resources/ash_wallpaper_resources.grd": None,
57
57
    "chrome/android/java/strings/android_chrome_strings.grd": None,
58
 
    "chrome/app/chromium_strings.grd": "chromium-strings",
59
 
    "chrome/app/generated_resources.grd": "generated-resources",
60
 
    "chrome/app/google_chrome_strings.grd": "app-strings",
61
 
    "chrome/app/policy/policy_templates.grd": "policy-templates",
 
58
    "chrome/app/chromium_strings.grd": "chromium_strings",
 
59
    "chrome/app/generated_resources.grd": "generated_resources",
 
60
    "chrome/app/google_chrome_strings.grd": "app_strings",
 
61
    "chrome/app/policy/policy_templates.grd": "policy_templates",
62
62
    "chrome/app/resources/locale_settings_chromiumos.grd": None,
63
63
    "chrome/app/resources/locale_settings_google_chromeos.grd": None,
64
64
    "chrome/app/resources/locale_settings.grd": None,   # Not strings.
92
92
    "device/device_bluetooth_strings.grd": None,
93
93
    "device/bluetooth/bluetooth_strings.grd": None,
94
94
    "net/base/net_resources.grd": "chromium-browser",
95
 
    "remoting/resources/common_resources.grd": "remoting-strings",
96
 
    "remoting/resources/remoting_strings.grd": "remoting-strings",
97
 
    "third_party/WebKit/public/blink_resources.grd": "webkit-strings",
 
95
    "remoting/resources/common_resources.grd": "remoting_strings",
 
96
    "remoting/resources/remoting_strings.grd": "remoting_strings",
 
97
    "third_party/WebKit/public/blink_resources.grd": "webkit_strings",
98
98
    "third_party/WebKit/Source/WebKit/chromium/WebKit.grd": "chromium-browser",
99
99
    "tools/grit/grit/testdata/buildinfo.grd": None,
100
100
    "tools/grit/grit/testdata/chrome/app/generated_resources.grd": None,
106
106
    "ui/resources/ui_resources.grd": "chromium-browser",
107
107
    "ui/resources/ui_unscaled_resources.grd": "chromium-browser",
108
108
    "ui/webui/resources/webui_resources.grd": "chromium-browser",
109
 
    "webkit/glue/inspector_strings.grd": "inspector-strings",
110
 
    "webkit/glue/resources/webkit_resources.grd": "webkit-strings",
111
 
    "webkit/glue/webkit_strings.grd": "webkit-strings",
 
109
    "webkit/glue/inspector_strings.grd": "inspector_strings",
 
110
    "webkit/glue/resources/webkit_resources.grd": "webkit_strings",
 
111
    "webkit/glue/webkit_strings.grd": "webkit_strings",
112
112
    "webkit/tools/test_shell/test_shell_resources.grd": None,
113
113
}
114
114
 
161
161
                    raise UnknownGrdTranslationDomain(filename)
162
162
 
163
163
                if not translation_domain:
164
 
                    logging.warn("Skipping %s file because it's in a quashed translation domain.", filename)
 
164
                    logging.debug("Skipping %s file because it's in a quashed translation domain.", filename)
165
165
                    continue
166
166
 
167
167
                if translation_domain not in txlns_infos:
209
209
                    raise UnknownGrdTranslationDomain(filename)
210
210
 
211
211
                if not translation_domain:
212
 
                    logging.warn("Skipping %s file because it's in a quashed translation domain.", filename)
 
212
                    logging.debug("Skipping %s file because it's in a quashed translation domain.", filename)
213
213
                    continue
214
214
 
215
215
                save_grd(txlns_infos[translation_domain], filename, import_cr_root, export_cr_root)
238
238
if __name__ == "__main__":
239
239
    import doctest, fileformats
240
240
    
 
241
    try:
 
242
        doctest.testmod(raise_on_error=True, exclude_empty=True, verbose=False)
 
243
        doctest.testmod(fileformats.xtb, raise_on_error=True, verbose=False)
 
244
        doctest.testmod(fileformats.grd, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
 
245
        doctest.testmod(fileformats.po, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
 
246
        doctest.testmod(fileformats.pot, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
 
247
        doctest.testmod(fileformats.gettext, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
 
248
    except doctest.DocTestFailure as exc:
 
249
        print("for test %s" % (exc.example.source.rstrip()))
 
250
        print("expected %s" % (exc.example.want.rstrip()))
 
251
        print(" but got %s" % (exc.got.rstrip()))
 
252
        raise
 
253
    except doctest.UnexpectedException as exc:
 
254
        import traceback
 
255
        print("%s  %s" % (exc.exc_info[0], exc.exc_info[1]))
 
256
        for line in traceback.format_tb(exc.exc_info[2]):
 
257
            print(line.rstrip())
 
258
        sys.exit(1)
 
259
 
241
260
    arg_parser = argparse.ArgumentParser()
242
261
    arg_parser.add_argument("-v", "--verbose", dest="verbose", action="store_true")
243
262
    arg_parser.add_argument("-p", "--profile", dest="profile", action="store_true")
248
267
    args = arg_parser.parse_args()
249
268
 
250
269
    if args.verbose:
251
 
        logging.basicConfig(level=logging.DEBUG, format="%(levelname).1s t%(relativeCreated)+d  %(module)s %(lineno)3d: %(message)s", stream=sys.stdout)
 
270
        logging.basicConfig(level=logging.INFO, format="%(levelname).1s t%(relativeCreated)+d  %(module)s %(lineno)3d: %(message)s", stream=sys.stdout)
252
271
        logging.debug("Verbose logging on.")
253
272
    else:
254
273
        logging.basicConfig(level=logging.WARNING, format="%(module)s %(lineno)3d: %(message)s", filename="run.log")
258
277
    translator_logger.addHandler(logging.FileHandler("notes-to-translators", "w"))
259
278
    translator_logger.setLevel(logging.DEBUG)
260
279
 
261
 
    try:
262
 
        doctest.testmod(raise_on_error=True, exclude_empty=True, verbose=False)
263
 
        doctest.testmod(fileformats.xtb, raise_on_error=True, verbose=False)
264
 
        doctest.testmod(fileformats.grd, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
265
 
        doctest.testmod(fileformats.po, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
266
 
        doctest.testmod(fileformats.pot, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
267
 
        doctest.testmod(fileformats.gettext, raise_on_error=True, verbose=False, optionflags=doctest.ELLIPSIS)
268
 
    except doctest.DocTestFailure as exc:
269
 
        logging.error("for test %s", exc.example.source.rstrip())
270
 
        logging.error("expected %s", exc.example.want.rstrip())
271
 
        logging.error(" but got %s", exc.got.rstrip())
272
 
        raise
273
 
    except doctest.UnexpectedException as exc:
274
 
        import traceback
275
 
        logging.error("for test %s", exc.example.source.rstrip())
276
 
        logging.error("expected %s", exc.example.want.rstrip())
277
 
        logging.error("%s  %s", exc.exc_info[0], exc.exc_info[1])
278
 
        for line in traceback.format_tb(exc.exc_info[2]):
279
 
            print(line.rstrip())
280
 
        sys.exit(1)
281
280
 
282
281
    if args.profile:
283
282
        import cProfile