Exemple #1
0
def extract_dependence(comment_lines):
    support_separartor = ",; "
    dependence = []
    for line in comment_lines:
        line = filter_line(line, DEPENDENCE_FLAG)
        if not line:
            continue
        parser = shlex.shlex(line)
        parser.whitespace += support_separartor
        parser.whitespace_split = True
        dependence += list(parser)
    return set(dependence)
Exemple #2
0
def extract_commands(comment_lines):
    commands = []
    flag = False
    merge_command = ""
    for command in comment_lines:
        command = filter_line(command, EXEC_FLAG)
        if not command:
            continue
        if command.strip()[-1] == "\\":
            flag = True
            merge_command += "{} ".format(command.strip()[:-1])
        else:
            if flag:
                merge_command += "{} ".format(command)
            flag = False
            if merge_command == "":
                commands.append(command)
            else:
                commands.append(merge_command)
                merge_command = ""
    if not commands and merge_command.strip():
        commands.append(merge_command)
    return commands
Exemple #3
0
def extract_expect(comment_lines):
    expect_line = [filter_line(line, EXPECT_FLAG) for line in comment_lines]
    expect_line = [line for line in expect_line if line]
    if not expect_line:
        return PASS
    return expect_line[-1]