def handle(self, args): app = EnumerateApp(args.ini_file, args.l10n_base_dir, args.locales) app.reference = args.reference try: observer = compareApp(app, merge_stage=args.merge, clobber=args.clobber) except (OSError, IOError), exc: print "FAIL: " + str(exc) self.parser.exit(2)
def handle(self, args, options): if len(args) < 2: self.parser.error('Need to pass in list of languages') inipath, l10nbase = args[:2] locales = args[2:] app = EnumerateApp(inipath, l10nbase, locales) app.reference = options.reference try: observer = compareApp(app, merge_stage=options.merge, clobber=options.clobber) except (OSError, IOError), exc: print "FAIL: " + str(exc) self.parser.exit(2)
def _compare(self, workingdir, locale, gather_stats, args): inipath, l10nbase = (self.args[k] for k in ('inipath', 'l10nbase')) app = EnumerateSourceTreeApp(os.path.join(workingdir, inipath), workingdir, os.path.join(workingdir, l10nbase), [locale]) obs = None stats = None if gather_stats: obs = Observer() o = compareApp(app, other_observer=obs) summary = o.summary[locale] if gather_stats: stats = obs.dict() return o, summary, stats
def compare(self, l10n_ini=None, l10n_base=None, merge_dir=None, locales=None): from compare_locales.paths import EnumerateApp from compare_locales.compare import compareApp # check if we're configured and use defaults from there # otherwise, error early try: self.substs # explicitly check if not l10n_ini: l10n_ini = mozpath.join( self.topsrcdir, self.substs['MOZ_BUILD_APP'], 'locales', 'l10n.ini' ) if not l10n_base: l10n_base = mozpath.join( self.topsrcdir, self.substs['L10NBASEDIR'] ) except Exception: if not l10n_ini or not l10n_base: print('Specify --l10n-ini and --l10n-base or run configure.') return 1 if not merge_dir: try: # self.substs is raising an Exception if we're not configured # don't merge if we're not merge_dir = mozpath.join( self.topobjdir, self.substs['MOZ_BUILD_APP'], 'locales', 'merge-{ab_CD}' ) except Exception: pass app = EnumerateApp(l10n_ini, l10n_base, locales) observer = compareApp(app, merge_stage=merge_dir, clobber=True) print(observer.serialize().encode('utf-8', 'replace'))