10
10
from shutil import copyfile
11
11
from pathlib import Path
12
12
13
-
14
13
# bail (printing a message beforehand) and exit
15
14
def Bail (message ):
16
15
print (f'Error: { message } ' )
@@ -21,29 +20,33 @@ def Bail(message):
21
20
parser = argparse .ArgumentParser (description = 'Script for packaging.' )
22
21
23
22
# stuff we gather from
24
- parser .add_argument ('--json ' , dest = 'path ' , required = True , type = str , help = 'path to npdmtool JSON file to gather information from ' )
23
+ parser .add_argument ('--codename ' , dest = 'codename ' , required = True , type = str , help = 'codename(s) of the build type ' )
25
24
parser .add_argument ('--subsdk' , dest = 'subsdk_name' , required = False , type = str , default = "subsdk9" , help = 'subsdk name (default \' subsdk9\' )' )
26
25
27
26
args = parser .parse_args ()
28
27
29
- if not os .path .exists (args .path ):
30
- Bail ("JSON file doesn't exist" )
28
+ for codename in args .codename .split (';' ):
29
+ print (f"Codename: { codename } " )
30
+ npdmPath = Path (os .getcwd ()) / f"../npdm/{ codename } .json"
31
+
32
+ if not os .path .exists (npdmPath ):
33
+ Bail ("NPDM JSON file doesn't exist" )
31
34
32
- with open (args . path , mode = 'r' ) as file :
33
- # additionaly if it doesn't have json data, it probably shouldn't be used either, bail there too.
34
- try :
35
- jsondata = json .loads (file .read ())
36
- except :
37
- Bail ("JSON file contains invalid data" )
35
+ with open (npdmPath , mode = 'r' ) as file :
36
+ # additionaly if it doesn't have json data, it probably shouldn't be used either, bail there too.
37
+ try :
38
+ jsondata = json .loads (file .read ())
39
+ except :
40
+ Bail ("NPDM JSON file contains invalid data" )
38
41
39
- programid = jsondata ['program_id' ][2 :].upper ()
42
+ programid = jsondata ['program_id' ][2 :].upper ()
40
43
41
- print (f"Gathered program id is { programid } " )
44
+ print (f"Gathered program id is { programid } " )
42
45
43
- amspath = Path (os .getcwd ()) / 'pkg' / 'atmosphere' / 'contents' / programid / 'exefs'
44
- amspath .mkdir (parents = True )
46
+ amspath = Path (os .getcwd ()) / 'pkg' / 'atmosphere' / 'contents' / programid / 'exefs'
47
+ amspath .mkdir (parents = True )
45
48
46
- copyfile ('xenomods.nso' , str (amspath / args .subsdk_name ))
47
- copyfile ('main .npdm' , str (amspath / 'main.npdm' ))
49
+ copyfile ('xenomods.nso' , str (amspath / args .subsdk_name ))
50
+ copyfile (f' { codename } .npdm' , str (amspath / 'main.npdm' ))
48
51
49
52
print ('Generated package data' )
0 commit comments