diff options
Diffstat (limited to 'resources/tools/presentation/environment.py')
-rw-r--r-- | resources/tools/presentation/environment.py | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/resources/tools/presentation/environment.py b/resources/tools/presentation/environment.py index 7cddb0279c..ea4d94ad70 100644 --- a/resources/tools/presentation/environment.py +++ b/resources/tools/presentation/environment.py @@ -21,7 +21,7 @@ import os import shutil import logging -from errors import PresentationError +from pal_errors import PresentationError class Environment: @@ -60,34 +60,37 @@ class Environment: """ if self._force: - logging.info("Removing old build(s) ...") - for directory in self._env["build-dirs"]: - dir_to_remove = self._env["paths"][directory] + logging.info(u"Removing old build(s) ...") + for directory in self._env[u"build-dirs"]: + dir_to_remove = self._env[u"paths"][directory] if os.path.isdir(dir_to_remove): try: shutil.rmtree(dir_to_remove) - logging.info(" Removed: {}".format(dir_to_remove)) + logging.info(f" Removed: {dir_to_remove}") except OSError: - raise PresentationError("Cannot remove the directory " - "'{}'".format(dir_to_remove)) - logging.info("Done.") + raise PresentationError( + f"Cannot remove the directory {dir_to_remove}" + ) + logging.info(u"Done.") - logging.info("Making directories ...") + logging.info(u"Making directories ...") - for directory in self._env["make-dirs"]: - dir_to_make = self._env["paths"][directory] + for directory in self._env[u"make-dirs"]: + dir_to_make = self._env[u"paths"][directory] try: if os.path.isdir(dir_to_make): - logging.warning("The directory '{}' exists, skipping.". - format(dir_to_make)) + logging.warning( + f"The directory {dir_to_make} exists, skipping." + ) else: os.makedirs(dir_to_make) - logging.info(" Created: {}".format(dir_to_make)) + logging.info(f" Created: {dir_to_make}") except OSError: - raise PresentationError("Cannot make the directory '{}'". - format(dir_to_make)) + raise PresentationError( + f"Cannot make the directory {dir_to_make}" + ) - logging.info("Done.") + logging.info(u"Done.") def set_environment(self): """Set the environment. @@ -101,28 +104,26 @@ def clean_environment(env): :param env: Environment specification. :type env: dict - :raises: PresentationError if it is not possible to remove a directory. """ - logging.info("Cleaning the environment ...") + logging.info(u"Cleaning the environment ...") - if not env["remove-dirs"]: # None or empty - logging.info(" No directories to remove.") + if not env[u"remove-dirs"]: # None or empty + logging.info(u" No directories to remove.") return - for directory in env["remove-dirs"]: - dir_to_remove = env["paths"][directory] - logging.info(" Removing the working directory {} ...". - format(dir_to_remove)) + for directory in env[u"remove-dirs"]: + dir_to_remove = env[u"paths"][directory] + logging.info(f" Removing the working directory {dir_to_remove} ...") if os.path.isdir(dir_to_remove): try: shutil.rmtree(dir_to_remove) except OSError as err: - logging.warning("Cannot remove the directory '{}'". - format(dir_to_remove)) + logging.warning( + f"Cannot remove the directory {dir_to_remove}" + ) logging.debug(str(err)) else: - logging.warning("The directory '{}' does not exist.". - format(dir_to_remove)) + logging.warning(f"The directory {dir_to_remove} does not exist.") - logging.info("Done.") + logging.info(u"Done.") |