-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCR_script.py
More file actions
executable file
·81 lines (66 loc) · 3.2 KB
/
Copy pathCR_script.py
File metadata and controls
executable file
·81 lines (66 loc) · 3.2 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
# external modules
import re
# my modules
import DCC
import Config as CF
import Tree
import MyUtil
s = DCC.login(CF.dcc_url + CF.dcc_login)
top_collection = 'Collection-4325'
while True:
cr_coll = input('\n>>>> Enter a Collection number (e.g. 1234) or Q to quit: ')
if 'Q' in cr_coll.upper():
print('\n\n....Quitting')
exit(0)
# if 'L' in cr_coll.upper():
# print('\n\n....Listing Collections')
# tree = Tree.get_tree(s, top_collection)
# Tree.print_tree(s,tree)
# break
cr_coll = 'Collection-' + cr_coll
print('\n')
fd = DCC.prop_get(s, cr_coll, InfoSet = 'CollData')
fd['parents'] = DCC.prop_get(s, cr_coll, InfoSet = 'Parents')
DCC.print_coll_data(fd)
DCC.print_parents(fd['parents'])
print('\n')
ans = input('>>>> Is this the correct collection? (Y/N):')
if ans.upper() == 'Y':
p = re.compile('CR\d+')
# print(p.match(fd['title']))
crnum = p.match(fd['title'])
crnum = crnum.group()
print(crnum)
list = [{'chandle':'Collection-14278', 'cname':'0.0 Change Control Requests - CR Pre-SE Acceptance','keyword':'CR - Pre-SE Acceptance'},
{'chandle':'Collection-14086', 'cname':'1.1 Change Control Requests - CR Initiated - CCB','keyword':'CR - Initiated - CCB'},
{'chandle':'Collection-14087', 'cname':'1.2 Change Control Requests - CR Initiated - No CCB','keyword':'CR - Initiated - No CCB'},
{'chandle':'Collection-12030', 'cname':'2.0 Change Control Requests - CR Evaluation','keyword':'CR - Evaluation'},
{'chandle':'Collection-12032', 'cname':'3.0 Change Control Requests - CCB','keyword':'CR - CCB'},
{'chandle':'Collection-12033', 'cname':'4.0 Change Control Requests - CR Implementation ','keyword':'CR - Implementation'},
{'chandle':'Collection-1004', 'cname':'5.0 Change Control Requests - CR Archive','keyword':'CR - Archived'},
]
idx = 0
for l in list:
print('[',idx,'] : ', l['cname'])
idx = idx + 1
ans = input('\n>>>> Choose a new location for the Collection [1-6] or Q:')
if 'Q' in ans.upper():
print('\n\n....Not making any changes')
else:
# Remove collection from all change control collections
ansnum = int(ans)
dest = list[ansnum]['chandle']
for l in list:
for p in fd['parents']:
if p[0] == l['chandle']:
if dest != l['chandle']: # don't move if it's already in the desired collection
DCC.dcc_move(s, cr_coll, l['chandle'], dest)
# Set keywords
DCC.set_metadata(s, cr_coll, Keywords = crnum + ': ' + list[ansnum]['keyword'])
DCC.set_metadata(s, cr_coll, Summary = crnum + ': ' + list[ansnum]['keyword'])
print('\n')
fd = DCC.prop_get(s, cr_coll, InfoSet = 'CollData')
fd['parents'] = DCC.prop_get(s, cr_coll, InfoSet = 'Parents')
DCC.print_coll_data(fd)
DCC.print_parents(fd['parents'])