Exemple #1
0
    def complete(self, line, begidx):
        self.shell_key = [";", "<", ">", "&", "|", "&", ";"]
        self.cmd_key = ["--modules"]
        self.cmd_key.extend([i for i in self.lmodules])
        self.args, self.bopt = utils.split_line(line)
        self.cur_str = ""
        self.prev_str = ""
        self.prev_arg = None
        self.cdl = None
        self.cvl = None
        matches = []
        start_scope_idx = 0
        end_scope_idx = len(self.args)

        for item in self.bopt:
            if item["arg"][0] in self.shell_key or item["arg"] == "--modules":
                if begidx >= item["end"]:
                    start_scope_idx = self.bopt.index(item) + 1
                    self.prev_str = ""
                    self.cur_str = ""
                else:
                    end_scope_idx = self.bopt.index(item)
            else:
                if begidx >= item["start"] and begidx <= item["end"]:
                    self.cur_str = item["arg"]
                if item["end"] < begidx:
                    self.prev_str = item["arg"]

        self.args = self.args[start_scope_idx:end_scope_idx]

        if self.prev_str == "":
            if len(self.args) == 0:
                matches = self.complete_modules()
            elif len(self.args) == 1 and self.cur_str != "":
                matches = self.complete_modules()
            else:
                matches = ""

        else:
            conf = self.get_conf(self.args[0])
            if conf != None:
                self.cdl = conf.descr_l
                self.cvl = conf.val_l
                #print "prev:", self.prev_str, "cur:", self.cur_str
            
                for i in range(len(self.cdl)):
                    arg = "--" + self.cdl[i].name
                    if arg == self.prev_str:
                        self.prev_arg = self.cdl[i]
                    if self.cur_str == None or self.cur_str == "":
                        matches = self.complete_empty()
                    else:
                        matches = self.complete_current()
            else:
                matches = ""

        if isinstance(matches, list) and len(matches) == 1:
            return matches[0]
        else:
            return matches
Exemple #2
0
    def complete(self, line, begidx):
        self.shell_key = [";", "<", ">", "&", "|", "&", ";"]
        self.cmd_key = ["--modules"]
        self.cmd_key.extend([i for i in self.lmodules])
        self.args, self.bopt = utils.split_line(line)
        self.cur_str = ""
        self.prev_str = ""
        self.prev_arg = None
        self.cdl = None
        self.cvl = None
        matches = []
        start_scope_idx = 0
        end_scope_idx = len(self.args)

        for item in self.bopt:
            if item["arg"][0] in self.shell_key or item["arg"] == "--modules":
                if begidx >= item["end"]:
                    start_scope_idx = self.bopt.index(item) + 1
                    self.prev_str = ""
                    self.cur_str = ""
                else:
                    end_scope_idx = self.bopt.index(item)
            else:
                if begidx >= item["start"] and begidx <= item["end"]:
                    self.cur_str = item["arg"]
                if item["end"] < begidx:
                    self.prev_str = item["arg"]

        self.args = self.args[start_scope_idx:end_scope_idx]

        if self.prev_str == "":
            if len(self.args) == 0:
                matches = self.complete_modules()
            elif len(self.args) == 1 and self.cur_str != "":
                matches = self.complete_modules()
            else:
                matches = ""

        else:
            conf = self.get_conf(self.args[0])
            if conf != None:
                self.cdl = conf.descr_l
                self.cvl = conf.val_l
                #print "prev:", self.prev_str, "cur:", self.cur_str

                for i in range(len(self.cdl)):
                    arg = "--" + self.cdl[i].name
                    if arg == self.prev_str:
                        self.prev_arg = self.cdl[i]
                    if self.cur_str == None or self.cur_str == "":
                        matches = self.complete_empty()
                    else:
                        matches = self.complete_current()
            else:
                matches = ""

        if isinstance(matches, list) and len(matches) == 1:
            return matches[0]
        else:
            return matches
    def generate(self, line):
        self.args, bopt = utils.split_line(line)
        cmds = []
        cmd = []
        generated_arguments = []
        #generated_args
        for a in self.args:
            if a in ["|", "&", "&&", ">>", "<<", ">", "<"]:
 #               cmds.append(cmd)
  #              cmd = []
		pass
            else:
                cmd.append(a)
        cmds.append(cmd)
        for cmd in cmds:
            gen_arg = self.argument("input")
            gen_arg.thisown = 0
            if (self.string_to_arguments(cmd, gen_arg) != -1):
                exc = {}
                exc[cmd[0]] = gen_arg
                generated_arguments.append(exc)
            else:
                pass

        return generated_arguments
Exemple #4
0
def process_input(input_table, delimiter):
    return [split_line(line.rstrip(os.linesep), delimiter) for line in input_table]
Exemple #5
0
def process_input(input_table, delimiter):
    return [split_line(line.rstrip(os.linesep), delimiter) for line in input_table]