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


Python Cmd.get_names方法代碼示例

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


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

示例1: do_help

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def do_help(self, line):
        """
    \x1b[32m\x1b[1mhelp\x1b[0m
    \x1b[32m\x1b[1mhelp\x1b[0m \x1b[34m\x1b[1m*\x1b[0m
    \x1b[32m\x1b[1mhelp\x1b[0m <\x1b[34m\x1b[1mcommand\x1b[0m> [\x1b[34m\x1b[1mcommand\x1b[0m...]

    Without arguments, shows the list of available commands.
    With arguments, shows the help for one or more commands.
    Use "\x1b[34m\x1b[1mhelp *\x1b[0m" to show help for all commands at once.
    The question mark "\x1b[34m\x1b[1m?\x1b[0m" can be used as an alias for "\x1b[34m\x1b[1mhelp\x1b[0m".\n"""
        if not line.strip():
            Cmd.do_help(self, line)
        else:
            commands = split(line, comments=True)
            if commands == ["*"]:
                commands = self.get_names()
                commands = [ x[3:] for x in commands if x.startswith("do_") ]
                commands.sort()
            last = len(commands) - 1
            index = 0
            for cmd in commands:
                Cmd.do_help(self, cmd)
                if index < last:
                    print Fore.RED + Style.BRIGHT + ("-" * 79) + Style.RESET_ALL
                index += 1 
開發者ID:nccgroup,項目名稱:thetick,代碼行數:27,代碼來源:tick.py

示例2: get_names

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def get_names(self):
        ret = []
        ret.extend(Cmd.get_names(self))
        ret.extend(self.extcmds.keys())
        return ret 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:7,代碼來源:cli.py

示例3: get_names

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def get_names(self):
        names = Cmd.get_names(self)
        names = [ x for x in set(names) if x.startswith('do_') ]
        names.sort()
        return names

    # Automatically autocomplete commands, even if Tab wasn't pressed.
    # The prefix is removed from the line and stored in self.cmdprefix.
    # Also implement the commands that consist of a symbol character. 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:11,代碼來源:interactive.py

示例4: do_help

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def do_help(self, arg):
        """
        ? - show the list of available commands
        ? * - show help for all commands
        ? <command> [command...] - show help for the given command(s)
        help - show the list of available commands
        help * - show help for all commands
        help <command> [command...] - show help for the given command(s)
        """
        if not arg:
            Cmd.do_help(self, arg)
        elif arg in ('?', 'help'):
            # An easter egg :)
            print("  Help! I need somebody...")
            print("  Help! Not just anybody...")
            print("  Help! You know, I need someone...")
            print("  Heeelp!")
        else:
            if arg == '*':
                commands = self.get_names()
                commands = [ x for x in commands if x.startswith('do_') ]
            else:
                commands = set()
                for x in arg.split(' '):
                    x = x.strip()
                    if x:
                        for n in self.completenames(x):
                            commands.add( 'do_%s' % n )
                commands = list(commands)
                commands.sort()
            print(self.get_help(commands)) 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:33,代碼來源:interactive.py

示例5: do_help

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def do_help(self, arg):
        """
        ? - show the list of available commands
        ? * - show help for all commands
        ? <command> [command...] - show help for the given command(s)
        help - show the list of available commands
        help * - show help for all commands
        help <command> [command...] - show help for the given command(s)
        """
        if not arg:
            Cmd.do_help(self, arg)
        elif arg in ('?', 'help'):
            # An easter egg :)
            print "  Help! I need somebody..."
            print "  Help! Not just anybody..."
            print "  Help! You know, I need someone..."
            print "  Heeelp!"
        else:
            if arg == '*':
                commands = self.get_names()
                commands = [ x for x in commands if x.startswith('do_') ]
            else:
                commands = set()
                for x in arg.split(' '):
                    x = x.strip()
                    if x:
                        for n in self.completenames(x):
                            commands.add( 'do_%s' % n )
                commands = list(commands)
                commands.sort()
            print self.get_help(commands) 
開發者ID:debasishm89,項目名稱:OpenXMolar,代碼行數:33,代碼來源:interactive.py

示例6: get_names

# 需要導入模塊: from cmd import Cmd [as 別名]
# 或者: from cmd.Cmd import get_names [as 別名]
def get_names(self):
            secret = "do_" + Console.secret
            names = Cmd.get_names(self)
            if secret in names:
                names.remove(secret)
            return names

# Dunno about you reversing it but I had fun coding this :D 
開發者ID:nccgroup,項目名稱:thetick,代碼行數:10,代碼來源:tick.py


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