From 6f6b761e3dee2e970fee4bfdff6c59278545da1a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 28 Aug 2021 07:21:44 +0200 Subject: [PATCH] do not raise if origin directory is deleted --- src/rougail/template/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rougail/template/base.py b/src/rougail/template/base.py index bcfe82bd6..5c0b50c45 100644 --- a/src/rougail/template/base.py +++ b/src/rougail/template/base.py @@ -308,7 +308,10 @@ class RougailBaseTemplate: async def instance_files(self) -> None: """Run templatisation on all files """ - ori_dir = getcwd() + try: + ori_dir = getcwd() + except FileNotFoundError: + ori_dir = None chdir(self.templates_dir) for option in await self.config.option.list(type='all'): namespace = await option.option.name() @@ -367,7 +370,8 @@ class RougailBaseTemplate: self.log.debug(_("Instantiation of file '{filename}' disabled")) self.post_instance_service(service_name, service_type) self.post_instance() - chdir(ori_dir) + if ori_dir is not None: + chdir(ori_dir) async def get_informations(self, type_: str,