3 if __name__ ==
'__main__':
4 import optparse, sys, re, yaml
5 parser = optparse.OptionParser()
6 parser.usage =
'Usage: %prog [options] inputfile(s)'
7 parser.add_option(
'--db', default=
'test_defects.db/COMP200',
8 help=
'Change database virtual defects will be added to')
9 parser.add_option(
'--create', default=
False, action=
'store_true',
10 help=
'Will create database if set')
11 parser.add_option(
'--tag', default=
'HEAD',
12 help=
'Choose tag to store virtual defects in')
17 opts, args = parser.parse_args()
26 tmp_indict = yaml.safe_load(
open(f,
'r'))
27 except yaml.scanner.ScannerError
as e:
28 print(
'ERROR: Problem parsing file', f)
32 print(
'NOTICE: No definitions in file', f)
34 interset =
set(tmp_indict) &
set(indict)
37 print(
'WARNING: Redefinition of defect', k,
'in file', f)
38 if not opts.ignore_redef:
40 indict.update(tmp_indict)
43 from DQDefects
import DefectsDB
44 from DQDefects.exceptions
import DefectUnknownError
45 ddb = DefectsDB(opts.db, create=opts.create, read_only=
False,
48 print(
'Now updating defects on', opts.db)
49 with ddb.storage_buffer:
50 for defect, clause
in indict.items():
53 ddb.update_virtual_defect(defect,
' '.
join(clause))
54 except DefectUnknownError:
55 ddb.new_virtual_defect(defect,
'',
' '.
join(clause))