Skip to content
Snippets Groups Projects
Commit 274e09cd authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[BUGFIX] small issues in new module generation

parent ad8c87b3
Branches
Tags
No related merge requests found
...@@ -33,7 +33,7 @@ class Module: ...@@ -33,7 +33,7 @@ class Module:
for root, dirnames, filenames in os.walk(self.context['module_path']): for root, dirnames, filenames in os.walk(self.context['module_path']):
for filename in filenames: for filename in filenames:
filedata = None filedata = None
print(f'{root}/{filename}') # print(f'renaming module name: {root}/{filename}')
with open(f'{root}/{filename}', 'r') as file: with open(f'{root}/{filename}', 'r') as file:
filedata = file.read() filedata = file.read()
...@@ -51,6 +51,8 @@ class Module: ...@@ -51,6 +51,8 @@ class Module:
mesa_pd_folder = (Path(__file__).parents[2] / 'src' / 'mesa_pd').resolve() mesa_pd_folder = (Path(__file__).parents[2] / 'src' / 'mesa_pd').resolve()
if (mesa_pd_folder != self.context['module_path']): 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.rmtree(self.context['module_path'])
shutil.copytree(mesa_pd_folder, 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): ...@@ -34,6 +34,9 @@ def generate_file(path, template, context={}, filename=None):
if filename == None: if filename == None:
filename = template.replace(".templ", "") filename = template.replace(".templ", "")
env = get_jinja_environment() env = get_jinja_environment()
if not (path / filename).exists():
print(f"{TerminalColor.YELLOW}skipping: {(path / filename)}{TerminalColor.DEFAULT}")
return
print(f"generating: {(path / filename)}") print(f"generating: {(path / filename)}")
with open(path / filename, "wb") as fout: with open(path / filename, "wb") as fout:
content = env.get_template(template).render(context) content = env.get_template(template).render(context)
......
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