-
Notifications
You must be signed in to change notification settings - Fork 1
/
ids.py
48 lines (48 loc) · 1.78 KB
/
ids.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
36
37
38
39
40
41
42
43
44
45
46
47
48
from . import util
from . import config
import glob
def PIDS(args):
for proj in util.listdir(f'{config.root}/projects/'):
if not proj.startswith('.'):
print(proj)
def BIDS(args):
validator = util.args_validator(args, 'p', '', 'bids')
validator.validate()
if not validator.is_valid():
validator.print_all(util.printc)
util.printc('usage: catena4j bids -p project_name')
return
if not util.exists(f'{config.root}/projects/{args.p}'):
util.printc('Project {args.p} does not exist')
return
if not util.exists(f'{config.root}/projects/{args.p}/bugs-registry.csv'):
util.printc('Invalid project directory: missing bugs registry')
return
ids = set()
with open(f'{config.root}/projects/{args.p}/bugs-registry.csv', 'r') as f:
registry = f.read().splitlines()[1:]
for line in registry:
ids.add(int(line[:line.find(',')]))
ids = list(ids)
ids.sort()
for bid in ids:
print(bid)
def CIDS(args):
validator = util.args_validator(args, 'pb', '', 'cids')
validator.validate()
if not validator.is_valid():
validator.print_all(util.printc)
util.printc('usage: catena4j cids -p project_name -b bug_id')
return
if not util.exists(f'{config.root}/projects/{args.p}'):
util.printc('Project {args.p} does not exist')
return
if not util.exists(f'{config.root}/projects/{args.p}/bugs-registry.csv'):
util.printc('Invalid project directory: missing bugs registry')
return
with open(f'{config.root}/projects/{args.p}/bugs-registry.csv', 'r') as f:
registry = f.read().splitlines()[1:]
for line in registry:
line = line.split(',')
if line[0].strip() == args.b:
print(line[1].strip())