aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/process_command_files.py
blob: 82626187ded1de7b5213742a0f33a434d420e1b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys 
 
 
def is_cmdfile_arg(arg): 
    return arg.startswith('@') 
 
def cmdfile_path(arg): 
    return arg[1:] 
 
def read_from_command_file(arg): 
    with open(arg) as afile: 
        return afile.read().splitlines() 
 
def skip_markers(args): 
    res = [] 
    for arg in args: 
        if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': 
            continue 
        res.append(arg) 
    return res 
 
def iter_args(args): 
    for arg in args: 
        if not is_cmdfile_arg(arg): 
            if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': 
                continue 
            yield arg 
        else: 
            for cmdfile_arg in read_from_command_file(cmdfile_path(arg)): 
                yield cmdfile_arg 
 
def get_args(args): 
    return list(iter_args(args))