4
4
You'll need to have a working CEA installation - including the CEA Console. It is assumed that this script
5
5
is run from the CEA Console using the version of Python shipped with the CEA.
6
6
"""
7
- from __future__ import print_function
8
-
9
- import os
10
- import uuid
11
7
import json
8
+ import os
12
9
import shutil
10
+ import uuid
11
+
13
12
import cea .config
14
13
import cea .scripts
15
14
22
21
def main ():
23
22
config = cea .config .Configuration (config_file = cea .config .DEFAULT_CONFIG )
24
23
script_defs = [] # a list of script defs in SCRIPTS_FILE
25
-
24
+
26
25
with open (SCRIPT_DEF_TEMPLATE_FILE , "r" ) as script_def_fp :
27
26
script_def_template = script_def_fp .read ()
28
27
@@ -31,10 +30,10 @@ def main():
31
30
32
31
# collect previous guids, if possible:
33
32
guids = {c ["name" ]: c ["id" ] for c in badgerfile ["components" ]}
34
-
33
+
35
34
badgerfile ["components" ] = []
36
- for script in cea .scripts .for_interface ("cli" ):
37
- script_py_name = script .name .replace ("-" , "_" )
35
+ for script in cea .scripts .for_interface ("cli" , plugins = [] ):
36
+ script_py_name = script .name .replace ("-" , "_" )
38
37
component = {
39
38
"id" : guids [script .label ] if script .label in guids else str (uuid .uuid4 ()),
40
39
"class-name" : "" .join (s .capitalize () for s in script .name .split ("-" )),
@@ -43,7 +42,7 @@ def main():
43
42
"description" : script .description ,
44
43
"category" : CATEGORY ,
45
44
"subcategory" : script .category ,
46
- "icon" : "icons/{name}.png" .format (name = script .name ),
45
+ "icon" : "icons/{name}.png" .format (name = script .name ),
47
46
"main-module" : "cea_scripts" ,
48
47
"main-function" : script_py_name ,
49
48
"use-kwargs" : True ,
@@ -59,15 +58,16 @@ def main():
59
58
"outputs" : [
60
59
{
61
60
"type" : "boolean" ,
62
- "name" : "continue" ,
61
+ "name" : "continue" ,
63
62
"description" : "This is set to true if component successfully ran and start was set to true" ,
64
63
"nick-name" : "continue"
65
64
}
66
65
],
67
66
}
68
- script_defs .append (script_def_template .replace ("SCRIPT_PY_NAME" , script_py_name ).replace ("SCRIPT_NAME" , script .name ))
67
+ script_defs .append (
68
+ script_def_template .replace ("SCRIPT_PY_NAME" , script_py_name ).replace ("SCRIPT_NAME" , script .name ))
69
69
print (script .name )
70
- for _ , parameter in config .matching_parameters (script .parameters ):
70
+ for _ , parameter in config .matching_parameters (script .parameters ):
71
71
print ("\t {pname}={pvalue}" .format (pname = parameter .name , pvalue = parameter .get_raw ()))
72
72
input = {
73
73
"type" : "string" ,
@@ -85,7 +85,6 @@ def main():
85
85
default_icon_path = os .path .join (os .path .dirname (__file__ ), "default_icon.png" )
86
86
if not os .path .exists (icon_path ):
87
87
shutil .copyfile (default_icon_path , icon_path )
88
-
89
88
90
89
with open (BADGERFILE , "w" ) as badger_fp :
91
90
json .dump (badgerfile , badger_fp , indent = 4 )
@@ -95,4 +94,4 @@ def main():
95
94
96
95
97
96
if __name__ == "__main__" :
98
- main ()
97
+ main ()
0 commit comments