當前位置: 首頁>>代碼示例>>Python>>正文


Python options.print_help方法代碼示例

本文整理匯總了Python中tornado.options.options.print_help方法的典型用法代碼示例。如果您正苦於以下問題:Python options.print_help方法的具體用法?Python options.print_help怎麽用?Python options.print_help使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.options.options的用法示例。


在下文中一共展示了options.print_help方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(self, file=None):
        """Prints all the command line options to stderr (or another file)."""
        if file is None:
            file = sys.stderr
        print("Usage: %s [OPTIONS]" % sys.argv[0], file=file)
        print("\nOptions:\n", file=file)
        by_group = {}
        for option in self._options.values():
            by_group.setdefault(option.group_name, []).append(option)

        for filename, o in sorted(by_group.items()):
            if filename:
                print("\n%s options:\n" % os.path.normpath(filename), file=file)
            o.sort(key=lambda option: option.name)
            for option in o:
                # Always print names with dashes in a CLI context.
                prefix = self._normalize_name(option.name)
                if option.metavar:
                    prefix += "=" + option.metavar
                description = option.help or ""
                if option.default is not None and option.default != '':
                    description += " (default %s)" % option.default
                lines = textwrap.wrap(description, 79 - 35)
                if len(prefix) > 30 or len(lines) == 0:
                    lines.insert(0, '')
                print("  --%-30s %s" % (prefix, lines[0]), file=file)
                for line in lines[1:]:
                    print("%-34s %s" % (' ', line), file=file)
        print(file=file) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:31,代碼來源:options.py

示例2: _help_callback

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def _help_callback(self, value):
        if value:
            self.print_help()
            sys.exit(0) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:6,代碼來源:options.py

示例3: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(file=None):
    """Prints all the command line options to stderr (or another file).

    See `OptionParser.print_help`.
    """
    return options.print_help(file) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:8,代碼來源:options.py

示例4: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(self, file: TextIO = None) -> None:
        """Prints all the command line options to stderr (or another file)."""
        if file is None:
            file = sys.stderr
        print("Usage: %s [OPTIONS]" % sys.argv[0], file=file)
        print("\nOptions:\n", file=file)
        by_group = {}  # type: Dict[str, List[_Option]]
        for option in self._options.values():
            by_group.setdefault(option.group_name, []).append(option)

        for filename, o in sorted(by_group.items()):
            if filename:
                print("\n%s options:\n" % os.path.normpath(filename), file=file)
            o.sort(key=lambda option: option.name)
            for option in o:
                # Always print names with dashes in a CLI context.
                prefix = self._normalize_name(option.name)
                if option.metavar:
                    prefix += "=" + option.metavar
                description = option.help or ""
                if option.default is not None and option.default != "":
                    description += " (default %s)" % option.default
                lines = textwrap.wrap(description, 79 - 35)
                if len(prefix) > 30 or len(lines) == 0:
                    lines.insert(0, "")
                print("  --%-30s %s" % (prefix, lines[0]), file=file)
                for line in lines[1:]:
                    print("%-34s %s" % (" ", line), file=file)
        print(file=file) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:31,代碼來源:options.py

示例5: _help_callback

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def _help_callback(self, value: bool) -> None:
        if value:
            self.print_help()
            sys.exit(0) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:6,代碼來源:options.py

示例6: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(self, file=None):
        """Prints all the command line options to stderr (or another file)."""
        if file is None:
            file = sys.stderr
        print("Usage: %s [OPTIONS]" % sys.argv[0], file=file)
        print("\nOptions:\n", file=file)
        by_group = {}
        for option in self._options.values():
            by_group.setdefault(option.group_name, []).append(option)

        for filename, o in sorted(by_group.items()):
            if filename:
                print("\n%s options:\n" % os.path.normpath(filename), file=file)
            o.sort(key=lambda option: option.name)
            for option in o:
                prefix = option.name
                if option.metavar:
                    prefix += "=" + option.metavar
                description = option.help or ""
                if option.default is not None and option.default != '':
                    description += " (default %s)" % option.default
                lines = textwrap.wrap(description, 79 - 35)
                if len(prefix) > 30 or len(lines) == 0:
                    lines.insert(0, '')
                print("  --%-30s %s" % (prefix, lines[0]), file=file)
                for line in lines[1:]:
                    print("%-34s %s" % (' ', line), file=file)
        print(file=file) 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:30,代碼來源:options.py

示例7: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(file: TextIO = None) -> None:
    """Prints all the command line options to stderr (or another file).

    See `OptionParser.print_help`.
    """
    return options.print_help(file) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:8,代碼來源:options.py

示例8: parse_command_line

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def parse_command_line(self, args=None):
        if args is None:
            args = sys.argv
        remaining = []
        for i in xrange(1, len(args)):
            # All things after the last option are command line arguments
            if not args[i].startswith("-"):
                remaining = args[i:]
                break
            if args[i] == "--":
                remaining = args[i + 1:]
                break
            arg = args[i].lstrip("-")
            name, equals, value = arg.partition("=")
            name = name.replace('-', '_')
            if not name in self:
                print_help()
                raise Error('Unrecognized command line option: %r' % name)
            option = self[name]
            if not equals:
                if option.type == bool:
                    value = "true"
                else:
                    raise Error('Option %r requires a value' % name)
            option.parse(value)
        if self.help:
            print_help()
            sys.exit(0)

        # Set up log level and pretty console logging by default
        if self.logging != 'none':
            logging.getLogger().setLevel(getattr(logging, self.logging.upper()))
            enable_pretty_logging()

        return remaining 
開發者ID:omererdem,項目名稱:honeything,代碼行數:37,代碼來源:options.py

示例9: print_help

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import print_help [as 別名]
def print_help(self, file=sys.stdout):
        """Prints all the command line options to stdout."""
        print >> file, "Usage: %s [OPTIONS]" % sys.argv[0]
        print >> file, "\nOptions:\n"
        by_group = {}
        for option in self.itervalues():
            by_group.setdefault(option.group_name, []).append(option)

        for filename, o in sorted(by_group.items()):
            if filename:
                print >> file, "\n%s options:\n" % os.path.normpath(filename)
            o.sort(key=lambda option: option.name)
            for option in o:
                prefix = option.name
                if option.metavar:
                    prefix += "=" + option.metavar
                description = option.help or ""
                if option.default is not None and option.default != '':
                    description += " (default %s)" % option.default
                lines = textwrap.wrap(description, 79 - 35)
                if len(prefix) > 30 or len(lines) == 0:
                    lines.insert(0, '')
                print >> file, "  --%-30s %s" % (prefix, lines[0])
                for line in lines[1:]:
                    print >> file, "%-34s %s" % (' ', line)
        print >> file 
開發者ID:omererdem,項目名稱:honeything,代碼行數:28,代碼來源:options.py


注:本文中的tornado.options.options.print_help方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。