Commit 274e09cd authored by Sebastian Eibl's avatar Sebastian Eibl

[BUGFIX] small issues in new module generation

parent ad8c87b3
Pipeline #22620 passed with stages
in 469 minutes and 36 seconds
......@@ -33,7 +33,7 @@ class Module:
for root, dirnames, filenames in os.walk(self.context['module_path']):
for filename in filenames:
filedata = None
print(f'{root}/{filename}')
# print(f'renaming module name: {root}/{filename}')
with open(f'{root}/{filename}', 'r') as file:
filedata = file.read()
......@@ -51,6 +51,8 @@ class Module:
mesa_pd_folder = (Path(__file__).parents[2] / 'src' / 'mesa_pd').resolve()
if (mesa_pd_folder != self.context['module_path']):
if not self.context['module_path'].exists():
self.context['module_path'].mkdir()
shutil.rmtree(self.context['module_path'])
shutil.copytree(mesa_pd_folder, self.context['module_path'])
......
......@@ -34,6 +34,9 @@ def generate_file(path, template, context={}, filename=None):
if filename == None:
filename = template.replace(".templ", "")
env = get_jinja_environment()
if not (path / filename).exists():
print(f"{TerminalColor.YELLOW}skipping: {(path / filename)}{TerminalColor.DEFAULT}")
return
print(f"generating: {(path / filename)}")
with open(path / filename, "wb") as fout:
content = env.get_template(template).render(context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment