예제 #1
0
파일: cmdline.py 프로젝트: rybesh/pybtex
    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)
예제 #2
0
파일: errors.py 프로젝트: crodehacke/PISMcr
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)
예제 #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)
예제 #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
예제 #5
0
파일: cmdline.py 프로젝트: rybesh/pybtex
    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