Fixed path detecting

This commit is contained in:
koumakpet 2020-04-05 19:08:34 +02:00
parent d178190778
commit fb0486d271
2 changed files with 23 additions and 12 deletions

View file

@ -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

View file

@ -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]: