forked from EmInReLab/bugsPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
argument_parser.py
35 lines (30 loc) · 1.4 KB
/
argument_parser.py
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
34
35
import argparse
import sys
import os
import json
def arg_parser():
parser = argparse.ArgumentParser(description=' ')
parser.add_argument('-p', '--project', required=True, type=str, choices=get_projects(), help='')
parser.add_argument('-b', '--bug-no', required=True, type=int, help='')
parser.add_argument('-t', '--task', required=True, type=str, choices=['checkout', 'install', 'test', 'failing-test-only'], help='')
parser.add_argument('-c', '--test-case', required=False, type=int, help='')
parser.add_argument('-v', '--version', required=True, type=str, choices=['buggy', 'fixed'], help='')
parser.add_argument('-o', '--output', required=False, type=str, help='output folder')
param_dict = {}
args = parser.parse_args()
param_dict["project"] = args.project
param_dict["bug-no"] = args.bug_no
param_dict["version"] = args.version
param_dict["task"] = args.task
param_dict["test-case"] = args.test_case
param_dict["output"] = args.output
return param_dict
def get_projects():
SCRIPTDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
projects_set = set()
bug_file = open(os.path.join(SCRIPTDIR, "bug_metadata.json"), "r")
bug_list = json.load(bug_file)
for bug in bug_list:
projects_set.add(bug["repo_owner"] + '--' + bug['repo_name'])
bug_file.close()
return list(projects_set)