From 1b5edd4bf054417e4c2f495988e4593f56c96b6e Mon Sep 17 00:00:00 2001 From: Patrick Klein Date: Sat, 5 Oct 2019 22:52:40 +0200 Subject: [PATCH] Removed isinstance check and redundant path calculation. --- autorandr.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/autorandr.py b/autorandr.py index a2ac544..44e9ad2 100755 --- a/autorandr.py +++ b/autorandr.py @@ -619,9 +619,9 @@ def save_configuration(profile_path, profile_name, configuration, forced=False): if os.path.isfile(setup_path) and not forced: raise AutorandrException('Refusing to overwrite config "{}" without passing "--force"!'.format(profile_name)) - with open(os.path.join(profile_path, "config"), "w") as config: + with open(config_path, "w") as config: output_configuration(configuration, config) - with open(os.path.join(profile_path, "setup"), "w") as setup: + with open(setup_path, "w") as setup: output_setup(configuration, setup) @@ -1233,11 +1233,10 @@ def main(argv): "PROFILE_FOLDER": profile_folder, "MONITORS": ":".join(enabled_monitors(config)), }) + except AutorandrException as e: + raise e except Exception as e: - if isinstance(e, AutorandrException): - raise e - else: - raise AutorandrException("Failed to save current configuration as profile '%s'" % (options["--save"],), e) + raise AutorandrException("Failed to save current configuration as profile '%s'" % (options["--save"],), e) print("Saved current configuration as profile '%s'" % options["--save"]) sys.exit(0) -- 2.39.2