def collectFiles(aComparer, apps=None, locales=None): ''' returns new files, files to compare, files to remove apps or locales need to be given, apps is a list, locales is a hash mapping applications to languages. If apps is given, it will look up all-locales for all apps for the languages to test. 'toolkit' is added to the list of modules, too. ''' if not apps and not locales: raise RuntimeError, "collectFiles needs either apps or locales" if apps and locales: raise RuntimeError, "You don't want to give both apps or locales" if locales: apps = locales.keys() # add toolkit, with all of the languages of all apps all = set() for locs in locales.values(): all.update(locs) locales['toolkit'] = list(all) else: locales = Paths.allLocales(apps) modules = Paths.Modules(apps) en = FileCollector() l10n = FileCollector() # load filter functions for each app fltrs = [] for app in apps: filterpath = 'mozilla/%s/locales/filter.py' % app if not os.path.exists(filterpath): continue l = {} execfile(filterpath, {}, l) if 'test' not in l or not callable(l['test']): logging.debug('%s does not define function "test"' % filterpath) continue fltrs.append(l['test']) # define fltr function to be used, calling into the app specific ones # if one of our apps wants us to know about a triple, make it so def fltr(mod, lpath, entity=None): for f in fltrs: keep = True try: keep = f(mod, lpath, entity) except Exception, e: logging.error(str(e)) if not keep: return False return True
def collectFiles(aComparer, apps = None, locales = None): ''' returns new files, files to compare, files to remove apps or locales need to be given, apps is a list, locales is a hash mapping applications to languages. If apps is given, it will look up all-locales for all apps for the languages to test. 'toolkit' is added to the list of modules, too. ''' if not apps and not locales: raise RuntimeError, "collectFiles needs either apps or locales" if apps and locales: raise RuntimeError, "You don't want to give both apps or locales" if locales: apps = locales.keys() # add toolkit, with all of the languages of all apps all = set() for locs in locales.values(): all.update(locs) locales['toolkit'] = list(all) else: locales = Paths.allLocales(apps) modules = Paths.Modules(apps) en = FileCollector() l10n = FileCollector() # load filter functions for each app fltrs = [] for app in apps: filterpath = 'mozilla/%s/locales/filter.py' % app if not os.path.exists(filterpath): continue l = {} execfile(filterpath, {}, l) if 'test' not in l or not callable(l['test']): logging.debug('%s does not define function "test"' % filterpath) continue fltrs.append(l['test']) # define fltr function to be used, calling into the app specific ones # if one of our apps wants us to know about a triple, make it so def fltr(mod, lpath, entity = None): for f in fltrs: keep = True try: keep = f(mod, lpath, entity) except Exception, e: logging.error(str(e)) if not keep: return False return True