コード例 #1
0
 def complete(self, ctx, incomplete):
     # got from click.termui.style
     if "," not in incomplete and ":" not in incomplete:
         candidates = self.colors + [key + "-" for key in self.args.keys()]
         candidates = [
             candidate for candidate in candidates
             if startswith(candidate, incomplete)
         ]
         if len(candidates) == 1:
             incomplete = candidates[0]
         tested = incomplete
         prefix = ""
     valuematch = re.match(
         "^(?P<prefix>.*?)(?P<key>[^,:]+)-(?P<value>[^,]*)$", incomplete)
     keymatch = re.match("^(?P<prefix>.*?),(?P<key>[^,:]*)$", incomplete)
     if valuematch:
         prefix, key, value = valuematch.groups()
         candidates = self.args.get(key, [])
         tested = value or ""
         prefix = "{}{}-".format(prefix, key)
     elif keymatch:
         prefix, key = keymatch.groups()
         candidates = [key_ + "-" for key_ in self.args.keys()]
         tested = key
         prefix = "{},".format(prefix)
     return [
         prefix + str(candidate) for candidate in candidates
         if startswith(str(candidate), tested)
     ]
コード例 #2
0
ファイル: slack.py プロジェクト: Konubinix/Devel
 def complete(self, ctx, incomplete):
     return [
         user["name"] for user in config.slack.users.values()
         if startswith(user.name, incomplete)
         or (user.email and startswith(user.email, incomplete))
         or startswith(user["real_name"], incomplete)
         or startswith(user["display_name"], incomplete)
     ]
コード例 #3
0
    def complete(self, ctx, incomplete):
        @cache_disk(expire=600)
        def get_candidates(parent_path):
            if parent_path != config.main_command.path:
                candidates = [
                    (parent_path + "." + cmd,
                     (get_command_safe(parent_path + "." + cmd).short_help if
                      get_command_safe(parent_path + "." +
                                       cmd) is not None else "Broken command"))
                    for cmd in list_commands(parent_path)
                ]
            else:
                candidates = [
                    (cmd,
                     (get_command_safe(cmd).short_help if get_command_safe(cmd)
                      is not None else "Broken command"))
                    for cmd in list_commands(config.main_command.path)
                ] + [(config.main_command.path, "Main parameters")]
            period_candidates = [
                (elem[0] + ".", None) for elem in candidates
                if isinstance(get_command_safe(elem[0]), Group)
            ]
            candidates += period_candidates
            return candidates

        if "." in incomplete:
            split = incomplete.split(".")
            parent_path = ".".join(split[:-1])
        else:
            parent_path = config.main_command.path
        candidates = get_candidates(parent_path)
        return [(cmd, cmd_help) for cmd, cmd_help in candidates
                if startswith(cmd, incomplete) and (
                    self.recursive or "." not in cmd)]
コード例 #4
0
 def complete(self, ctx, incomplete):
     completion = set()
     for path in self.path(ctx):
         for file in os.listdir(path):
             if startswith(file, incomplete):
                 completion.add(file)
     return completion
コード例 #5
0
ファイル: navitia.py プロジェクト: Konubinix/Devel
 def complete(self, ctx, incomplete):
     @cache_disk(expire=3600)
     def _list_rest(*args, **kwargs):
         return self.list(*args, **kwargs)
     url = re.sub('[^/]+$', '', incomplete)
     res = [(u, ' '.join(p)) for u, p in _list_rest(url, True, False) if startswith(u, incomplete)]
     res += [(s[0] + '/', None) for s in res]
     return res
コード例 #6
0
ファイル: launcher.py プロジェクト: zpyoung/click-project
 def complete(self, ctx, incomplete):
     choices = [
         " ".join([quote(v) for v in value])
         for value in config.settings.get("launchers", {}).values()
     ]
     return [
         launcher for launcher in choices
         if startswith(launcher, incomplete)
     ]
コード例 #7
0
    def complete(self, ctx, incomplete):
        @cache_disk(expire=600)
        def get_shortdoc(path):
            cmd = get_command_safe(path)
            if cmd is None:
                return "Broken command"
            else:
                return cmd.short_help

        choices = [(path, get_shortdoc(path))
                   for path in self.settings(ctx).keys()]
        return [(cmd, cmd_help) for cmd, cmd_help in choices
                if startswith(cmd, incomplete)]
コード例 #8
0
 def complete(self, ctx, incomplete):
     return [clr for clr in git_remotes() if startswith(clr, incomplete)]
コード例 #9
0
ファイル: plugins.py プロジェクト: zpyoung/click-project
 def complete(self, ctx, incomplete):
     choice = self.getchoice(ctx)
     return [(plugin, load_short_help(plugin)) for plugin in choice
             if startswith(plugin, incomplete)]
コード例 #10
0
ファイル: launcher.py プロジェクト: zpyoung/click-project
 def complete(self, ctx, incomplete):
     choices = config.settings.get("launchers", {}).keys()
     return [
         launcher for launcher in choices
         if startswith(launcher, incomplete)
     ]
コード例 #11
0
 def complete(self, ctx, incomplete):
     return [
         candidate for candidate in self.choices
         if startswith(candidate, incomplete)
     ]
コード例 #12
0
 def complete(self, ctx, incomplete):
     return [
         name for name in self.choices() if startswith(name, incomplete)
     ]
コード例 #13
0
 def complete(self, ctx, incomplete):
     return (choice for choice in self.choices
             if startswith(choice, incomplete))
コード例 #14
0
 def complete(self, ctx, incomplete):
     if _remote:
         return [clr for clr in self.refs if startswith(clr, incomplete)]
     else:
         return []
コード例 #15
0
 def complete(self, ctx, incomplete):
     return [clr for clr in self.refs if startswith(clr, incomplete)]
コード例 #16
0
ファイル: slack.py プロジェクト: Konubinix/Devel
 def complete(self, ctx, incomplete):
     return [
         c.name for c in config.slack.conversations.values()
         if startswith(c.name, incomplete)
     ]
コード例 #17
0
 def complete(self, ctx, incomplete):
     choice = self.getchoice(ctx)
     return [(recipe, load_short_help(recipe)) for recipe in choice
             if startswith(recipe, incomplete)]