Skip to content

Commit

Permalink
Add support for importing other files from package and assembly confi…
Browse files Browse the repository at this point in the history
…guration files (#46)
  • Loading branch information
openvmp authored Jan 7, 2024
1 parent 55b7d0e commit f6e140c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"bierner.markdown-checkbox",
"bierner.markdown-yaml-preamble",
"bierner.markdown-footnotes",
"bierner.markdown-mermaid"
"bierner.markdown-mermaid",
// Jinja2
"samuelcolvin.jinjahtml",
]
}
6 changes: 4 additions & 2 deletions src/partcad/assembly_factory_assy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

import build123d as b3d
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
import logging
import os
import yaml
Expand All @@ -32,7 +32,9 @@ def instantiate(self, assembly):
fp.close()

# Resolve Jinja templates
template = Template(config)
template = Environment(
loader=FileSystemLoader(os.path.dirname(self.path) + os.path.sep)
).from_string(config)
config = template.render(
name=self.assembly_config["name"],
)
Expand Down
6 changes: 4 additions & 2 deletions src/partcad/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Licensed under Apache License, Version 2.0.

from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
import json
import logging
import os
Expand Down Expand Up @@ -40,7 +40,9 @@ def __init__(self, import_config_name, config_path=DEFAULT_CONFIG_FILENAME):
fp.close()

# Resolve Jinja templates
template = Template(config)
template = Environment(
loader=FileSystemLoader(self.config_dir + os.path.sep)
).from_string(config)
config = template.render(
package_name=import_config_name,
)
Expand Down

0 comments on commit f6e140c

Please sign in to comment.