From cd0a9456cb20cb862140409d49f72c3dbdde59ee Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 7 Apr 2019 22:41:41 -0700 Subject: [PATCH] Use pathlib.Path to resolve paths * is_block_device() is no longer needed * (pathlib.Path provides that functionality) --- .bin/Scripts/functions/ufd.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.bin/Scripts/functions/ufd.py b/.bin/Scripts/functions/ufd.py index 654f1f27..441b4770 100644 --- a/.bin/Scripts/functions/ufd.py +++ b/.bin/Scripts/functions/ufd.py @@ -1,24 +1,21 @@ # Wizard Kit: Functions - UFD +import pathlib from functions.common import * def get_full_path(item): - """Get full path to item, returns str.""" - #TODO - pass + """Get full path to item, returns pathlib.Path obj.""" + path_obj = pathlib.Path(item).resolve() + if not path_obj.exists(): + raise FileNotFoundError(path_obj) + + return path_obj -def is_block_device(item): - """Verify item is a block device, returns bool.""" - #TODO - pass - - -def is_valid_main_kit(path): - """Verify path contains the main kit, returns bool.""" - #TODO - pass +def is_valid_main_kit(path_obj): + """Verify PathObj contains the main kit, returns bool.""" + return path_obj.is_dir() and path_obj.joinpath('.bin').exists() if __name__ == '__main__':