From 274e09cd404010e87a45c6a21f4eee5d0d7ec80a Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Fri, 13 Mar 2020 10:53:47 +0100 Subject: [PATCH] [BUGFIX] small issues in new module generation --- python/mesa_pd/Module.py | 4 +++- python/mesa_pd/utility.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python/mesa_pd/Module.py b/python/mesa_pd/Module.py index dc94b5fbf..eec965f3e 100644 --- a/python/mesa_pd/Module.py +++ b/python/mesa_pd/Module.py @@ -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']) diff --git a/python/mesa_pd/utility.py b/python/mesa_pd/utility.py index b5a86337d..0475b988b 100644 --- a/python/mesa_pd/utility.py +++ b/python/mesa_pd/utility.py @@ -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) -- GitLab