diff --git a/dotfiles_install.py b/dotfiles_install.py index f676051..210c6cc 100644 --- a/dotfiles_install.py +++ b/dotfiles_install.py @@ -53,8 +53,8 @@ class InstallationChecks: oh_my_zsh_path = InstallationChecks.get_installation_path( standard_paths) - if oh_my_zsh_path: # Check if package was found in standard paths - return True, oh_my_zsh_path + if oh_my_zsh_path[0]: # Check if package was found in standard paths + return True, oh_my_zsh_path[1] else: # Package wasn't found, try to install it return InstallationChecks.install_package('oh-my-zsh', standard_paths, @@ -71,8 +71,9 @@ class InstallationChecks: zsh_highlight_path = InstallationChecks.get_installation_path( standard_paths) - if zsh_highlight_path: # Check if package was found in standard paths - return True, zsh_highlight_path + if zsh_highlight_path[ + 0]: # Check if package was found in standard paths + return True, zsh_highlight_path[1] else: # Package wasn't found, try to install it return InstallationChecks.install_package( 'zsh-syntax-highlighting', standard_paths, @@ -226,7 +227,7 @@ class Dotfiles: return PersonalizedChanges.zshrc(self, file) elif 'vimrc' in file: return PersonalizedChanges.vimrc(file) - elif 'gitignore' in file: + elif '.gitconfig' in file: return PersonalizedChanges.gitconfig(file) else: return True diff --git a/util/Path.py b/util/Path.py index 851251d..ecda364 100644 --- a/util/Path.py +++ b/util/Path.py @@ -14,9 +14,14 @@ def check_dir_exists(paths): Returns: bool -- One of dirs exists/Single dir exists ''' - if type(paths) != str: - paths = str(paths) - paths = paths.split(' ') + if type(paths) == pathlib.PosixPath: + paths = [str(paths)] + elif type(paths) == str: + paths = paths.split(' ') + elif type(paths) != list: + raise TypeError( + f'check_dir_exists() can only accept list, str or pathlib.PosixPath, not {type(paths)}' + ) for dir_path in paths: dir_path = os.path.expanduser(dir_path) if os.path.isdir(dir_path): @@ -35,9 +40,14 @@ def check_file_exists(paths): Returns: bool -- One of files exists/Single file exists ''' - if type(paths) != str: - paths = str(paths) - paths = paths.split(' ') + if type(paths) == pathlib.PosixPath: + paths = [str(paths)] + elif type(paths) == str: + paths = paths.split(' ') + elif type(paths) != list: + raise TypeError( + f'check_file_exists() can only accept list, str or pathlib.PosixPath, not {type(paths)}' + ) for file_path in paths: file_path = os.path.expanduser(file_path) if os.path.isfile(file_path): @@ -106,7 +116,7 @@ def ensure_dirs(path, file_end=False, absolute_path=True): ''' if not absolute_path: path = pathlib.Path(path).absolute() - if check_file_exists(path) or file_end: + if file_end: path = get_parent(path) if not check_dir_exists(path)[0]: