From 1047bcb08590b6b39ce2720d9bd7e3ea782ac0c2 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Sat, 23 Sep 2023 23:28:14 +0200 Subject: [PATCH] Refactor --- src/sinol_make/util.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sinol_make/util.py b/src/sinol_make/util.py index 6940520d..33348e40 100644 --- a/src/sinol_make/util.py +++ b/src/sinol_make/util.py @@ -29,9 +29,11 @@ def get_commands(): return commands -def check_if_package(): +def find_and_chdir_package(): """ - Function to check if current directory is a package + Checks if current directory or parent directory is a package directory. + If it is, it changes the current working directory to it and returns True. + If it isn't, it returns False. """ if os.path.exists(os.path.join(os.getcwd(), 'config.yml')): return True @@ -44,9 +46,11 @@ def check_if_package(): def exit_if_not_package(): """ - Function that exits if current directory is not a package + Checks if current directory or parent directory is a package directory. + If it is, current working directory is changed to it. + If it isn't, it exits with an error. """ - if not check_if_package(): + if not find_and_chdir_package(): exit_with_error('You are not in a package directory (couldn\'t find config.yml in current directory).')