Example #1
0
    def __call__(self):
        from pybtex.exceptions import PybtexError
        import pybtex.io

        try:
            self.main()
        except PybtexError, error:
            print >>pybtex.io.stderr, "ERROR: %s" % capfirst(add_period(unicode(error)))
            sys.exit(1)
Example #2
0
def format_error(exception, prefix='ERROR: '):
    lines = []
    context = exception.get_context()
    if context:
        lines += (context.splitlines())
    lines.append(u'{0}{1}'.format(prefix,
                                  capfirst(add_period(unicode(exception)))))
    filename = exception.get_filename()
    if filename:
        lines = (u'{0}: {1}'.format(filename, line) for line in lines)
    return '\n'.join(lines)
Example #3
0
def format_error(exception, prefix='ERROR: '):
    lines = []
    context = exception.get_context()
    if context:
        lines += (context.splitlines())
    lines.append(u'{0}{1}'.format(prefix, capfirst(add_period(unicode(exception)))))
    filename = exception.get_filename()
    if filename:
        lines = (
            u'{0}: {1}'.format(filename, line)
            for line in lines
        )
    return '\n'.join(lines)
Example #4
0
    def make_option_parser(self):
        opt_parser = optparse.OptionParser(prog=self.prog,
                                           option_class=PybtexOption,
                                           formatter=PybtexHelpFormatter(),
                                           usage='%prog ' + self.args,
                                           description=capfirst(
                                               add_period(self.description)),
                                           version='%%prog-%s' % version)
        for option_group, option_list in self.options:
            if option_group is None:
                container = opt_parser
            else:
                container = opt_parser.add_option_group(option_group)
            for option in option_list:
                container.add_option(option)

        if self.option_defaults:
            opt_parser.set_defaults(**self.option_defaults)

        return opt_parser
Example #5
0
    def make_option_parser(self):
        opt_parser = optparse.OptionParser(
            prog=self.prog,
            option_class=PybtexOption,
            formatter=PybtexHelpFormatter(),
            usage="%prog " + self.args,
            description=capfirst(add_period(self.description)),
            version="%%prog-%s" % version,
        )
        for option_group, option_list in self.options:
            if option_group is None:
                container = opt_parser
            else:
                container = opt_parser.add_option_group(option_group)
            for option in option_list:
                container.add_option(option)

        if self.option_defaults:
            opt_parser.set_defaults(**self.option_defaults)

        return opt_parser