Skip to content

Commit 0515260

Browse files
committed
porting to py3 for compatibility with cea 3.13
1 parent 6825bf3 commit 0515260

File tree

6 files changed

+3179
-3226
lines changed

6 files changed

+3179
-3226
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1+
.idea/*
22
_build/*

cea-compile-grasshopper.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
You'll need to have a working CEA installation - including the CEA Console. It is assumed that this script
55
is run from the CEA Console using the version of Python shipped with the CEA.
66
"""
7-
from __future__ import print_function
8-
9-
import os
10-
import uuid
117
import json
8+
import os
129
import shutil
10+
import uuid
11+
1312
import cea.config
1413
import cea.scripts
1514

@@ -22,7 +21,7 @@
2221
def main():
2322
config = cea.config.Configuration(config_file=cea.config.DEFAULT_CONFIG)
2423
script_defs = [] # a list of script defs in SCRIPTS_FILE
25-
24+
2625
with open(SCRIPT_DEF_TEMPLATE_FILE, "r") as script_def_fp:
2726
script_def_template = script_def_fp.read()
2827

@@ -31,10 +30,10 @@ def main():
3130

3231
# collect previous guids, if possible:
3332
guids = {c["name"]: c["id"] for c in badgerfile["components"]}
34-
33+
3534
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("-", "_")
3837
component = {
3938
"id": guids[script.label] if script.label in guids else str(uuid.uuid4()),
4039
"class-name": "".join(s.capitalize() for s in script.name.split("-")),
@@ -43,7 +42,7 @@ def main():
4342
"description": script.description,
4443
"category": CATEGORY,
4544
"subcategory": script.category,
46-
"icon": "icons/{name}.png".format(name=script.name),
45+
"icon": "icons/{name}.png".format(name=script.name),
4746
"main-module": "cea_scripts",
4847
"main-function": script_py_name,
4948
"use-kwargs": True,
@@ -59,15 +58,16 @@ def main():
5958
"outputs": [
6059
{
6160
"type": "boolean",
62-
"name": "continue",
61+
"name": "continue",
6362
"description": "This is set to true if component successfully ran and start was set to true",
6463
"nick-name": "continue"
6564
}
6665
],
6766
}
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))
6969
print(script.name)
70-
for _, parameter in config.matching_parameters(script.parameters):
70+
for _, parameter in config.matching_parameters(script.parameters):
7171
print("\t{pname}={pvalue}".format(pname=parameter.name, pvalue=parameter.get_raw()))
7272
input = {
7373
"type": "string",
@@ -85,7 +85,6 @@ def main():
8585
default_icon_path = os.path.join(os.path.dirname(__file__), "default_icon.png")
8686
if not os.path.exists(icon_path):
8787
shutil.copyfile(default_icon_path, icon_path)
88-
8988

9089
with open(BADGERFILE, "w") as badger_fp:
9190
json.dump(badgerfile, badger_fp, indent=4)
@@ -95,4 +94,4 @@ def main():
9594

9695

9796
if __name__ == "__main__":
98-
main()
97+
main()

0 commit comments

Comments
 (0)