From d008e6a6b2f9d5e3ee65617b4ab525247a15f86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=82=AD?= Date: Wed, 4 Nov 2020 07:46:47 +0500 Subject: [PATCH] Improvements to build - removed redundant conditional, source: https://stackoverflow.com/questions/49917999/if-statements-made-redundant-by-else-statements - replaced if with if expression, https://www.guru99.com/if-loop-python-conditional-structures.html#:~:text=What%20is%20Python%20If%20Statement,code%20for%20the%20else%20condition. --- build.py | 7 ++----- src/build.py | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build.py b/build.py index 9dd464e..fbb0660 100644 --- a/build.py +++ b/build.py @@ -102,7 +102,7 @@ def build(path: str, flags: Dict[str, str] = {}, options: Dict[str, bool] = {}, if os.path.isfile(config_path) and not override: logging.warning(f"A config file exists at '{config_path}', keeping it") else: - if os.path.isfile(config_path) and override: + if os.path.isfile(config_path): logging.warning(f"Overriding config file at '{config_path}'") logging.debug(f"Generating config file at '{config_path}'") try: @@ -152,10 +152,7 @@ if __name__ == "__main__": "array_grow_factor": "2", "frames_max": "800" } - if args.verbose: - level = logging.DEBUG - else: - level = logging.INFO + level = logging.DEBUG if args.verbose else logging.INFO logging.basicConfig(format="[%(levelname)s - %(asctime)s] %(message)s", datefmt="%T", level=level diff --git a/src/build.py b/src/build.py index baea4ea..d916d96 100644 --- a/src/build.py +++ b/src/build.py @@ -68,10 +68,7 @@ if __name__ == "__main__": parser.add_argument("--flags", help="Optional flags to be passed to the nim compiler. Must be a comma-separated list of name:value (without spaces)") args = parser.parse_args() flags = {} - if args.verbose: - level = logging.DEBUG - else: - level = logging.INFO + level = logging.DEBUG if args.verbose else logging.INFO logging.basicConfig(format="[%(levelname)s - %(asctime)s] %(message)s", datefmt="%T", level=level