def main(): parser = cmdlineparser() parser.add_option("", "--nous", dest="filterclass", action="store_const", default=None, const=NousChecker, help="use the standard checks for Nous translations") parser.run()
def filter(self, translationstore, checkerconfig=None, cmdlineoptions=None): """Helper that passes a translations store through a filter, and returns the resulting store.""" if cmdlineoptions is None: cmdlineoptions = [] options, args = pofilter.cmdlineparser().parse_args([self.filename] + cmdlineoptions) checkerclasses = [checks.StandardChecker, checks.StandardUnitChecker] if checkerconfig is None: checkerconfig = checks.CheckerConfig() checkfilter = pofilter.pocheckfilter(options, checkerclasses, checkerconfig) tofile = checkfilter.filterfile(translationstore) return tofile
def filter(self, translationstore, checkerconfig=None, cmdlineoptions=None): """Helper that passes a translations store through a filter, and returns the resulting store.""" if cmdlineoptions is None: cmdlineoptions = [] options, args = pofilter.cmdlineparser().parse_args([self.filename] + cmdlineoptions) checkerclasses = [checks.StandardChecker, checks.StandardUnitChecker] if checkerconfig is None: checkerconfig = pofilter.build_checkerconfig(options) checkfilter = pofilter.pocheckfilter(options, checkerclasses, checkerconfig) tofile = checkfilter.filterfile(translationstore) return tofile
def check_po_syntax_error(self, fname): """Check po lint in fname. :param fname: String with full path of file to check :return: Return list of errors. """ newargv = ['pofilter', fname] with custom_sys_argv(newargv): parser = cmdlineparser() options = parser.parse_args()[0] with open(options.input, 'r') as pofile: fromfile = factory.getobject(pofile) polinter = PoLinter(options=options, checkerconfig=build_checkerconfig(options)) return list(polinter.get_syntax_error(fromfile))
def check_po_lint(self, fname, enabled, disabled): """Check po lint in fname. :param fname: String with full path of file to check :return: Return list of errors. """ newargv = ['pofilter', fname] if enabled: newargv.extend(['--test=%s' % f for f in enabled]) if disabled: newargv.extend(['--excludefilter=%s' % f for f in disabled]) with custom_sys_argv(newargv): parser = cmdlineparser() options = parser.parse_args()[0] with open(options.input, 'r') as pofile: fromfile = factory.getobject(pofile) polinter = PoLinter(options=options, checkerconfig=build_checkerconfig(options)) return list(polinter.get_errors_wlno(fromfile))