Skip to content

Commit 6bd6ba7

Browse files
fix deployment scripts (#321)
* Use safe_load and context managers for file handling in render.py (#1) Co-authored-by: Cursor Agent <[email protected]> * Changes from background composer bc-925563b9-8fb2-4df9-b99e-ebd3342eb01e (#2) Co-authored-by: Cursor Agent <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent 859463d commit 6bd6ba7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

deploy/render.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def scan_core_data(core_dir, validate_link=False):
2929
data_file = os.path.join(core_dir, category, data_item)
3030

3131
try:
32-
data_obj = yaml.load(open(data_file))
32+
with open(data_file, 'r') as f:
33+
data_obj = yaml.safe_load(f)
3334
data_obj["_rawFileName"] = data_item
3435
except Exception as e:
3536
raise RuntimeError("Failed to read YAML data: {}".format(e))
@@ -75,7 +76,8 @@ def do_validate_link(link):
7576

7677
categories = scan_core_data(core_dir, validate_link=True)
7778

78-
rendered = Template(open(template_file).read()).render(categories=categories)
79+
with open(template_file, 'r') as f:
80+
rendered = Template(f.read()).render(categories=categories)
7981
with open(os.path.join(pdir, "index.rst"), "w") as of:
8082
of.write(rendered)
8183
of.write("\n")

tools/parse_rst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ruamel.yaml import YAML
88

99
# Load template
10-
template = yaml.load(open('dataset.yml.template', 'rb').read())
10+
template = yaml.load(open('dataset.yml.template', 'rb').read(), Loader=yaml.Loader)
1111

1212
category = None
1313
categories = {}

0 commit comments

Comments
 (0)