@@ -24,6 +24,17 @@ def parse_args(args_):
24
24
parser .add_argument (
25
25
'source' , help = 'Input directory'
26
26
)
27
+ parser .add_argument (
28
+ '-user' ,
29
+ help = 'Declare who you are. If this is not set, you will be prompted.' )
30
+ parser .add_argument (
31
+ '-number' ,
32
+ help = 'Enter the Accession number for the representation.The parent Object Entry number will be replaced with this name.'
33
+ )
34
+ parser .add_argument (
35
+ '-force' ,
36
+ help = 'Renames OE with accession number without confirmation.' , action = 'store_true'
37
+ )
27
38
parsed_args = parser .parse_args (args_ )
28
39
return parsed_args
29
40
def main (args_ ):
@@ -36,18 +47,37 @@ def main(args_):
36
47
if uuid_directory is not None :
37
48
oe_path = os .path .dirname (uuid_directory )
38
49
oe_number = os .path .basename (oe_path )
39
- user = ififuncs .get_user ()
40
- accession_number = ififuncs .get_accession_number ()
50
+ if args .user :
51
+ user = args .user
52
+ else :
53
+ user = ififuncs .get_user ()
54
+ if args .number :
55
+ if args .number [:3 ] != 'aaa' :
56
+ print 'First three characters must be \' aaa\' and last four characters must be four digits'
57
+ accession_number = ififuncs .get_accession_number ()
58
+ elif len (args .number [3 :]) != 4 :
59
+ accession_number = ififuncs .get_accession_number ()
60
+ print 'First three characters must be \' aaa\' and last four characters must be four digits'
61
+ elif not args .number [3 :].isdigit ():
62
+ accession_number = ififuncs .get_accession_number ()
63
+ print 'First three characters must be \' aaa\' and last four characters must be four digits'
64
+ else :
65
+ accession_number = args .number
66
+ else :
67
+ accession_number = ififuncs .get_accession_number ()
41
68
accession_path = os .path .join (
42
69
os .path .dirname (oe_path ), accession_number
43
70
)
44
71
uuid = os .path .basename (uuid_directory )
45
72
new_uuid_path = os .path .join (accession_path , uuid )
46
73
logs_dir = os .path .join (new_uuid_path , 'logs' )
47
74
sipcreator_log = os .path .join (logs_dir , uuid ) + '_sip_log.log'
48
- proceed = ififuncs .ask_yes_no (
49
- 'Do you want to rename %s with %s' % (oe_number , accession_number )
50
- )
75
+ if args .force :
76
+ proceed = 'Y'
77
+ else :
78
+ proceed = ififuncs .ask_yes_no (
79
+ 'Do you want to rename %s with %s' % (oe_number , accession_number )
80
+ )
51
81
if proceed == 'Y' :
52
82
os .rename (oe_path , accession_path )
53
83
ififuncs .generate_log (
0 commit comments