mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-04-28 05:02:26 +00:00
Fixed path detecting
This commit is contained in:
parent
d178190778
commit
fb0486d271
2 changed files with 23 additions and 12 deletions
|
@ -53,8 +53,8 @@ class InstallationChecks:
|
||||||
oh_my_zsh_path = InstallationChecks.get_installation_path(
|
oh_my_zsh_path = InstallationChecks.get_installation_path(
|
||||||
standard_paths)
|
standard_paths)
|
||||||
|
|
||||||
if oh_my_zsh_path: # Check if package was found in standard paths
|
if oh_my_zsh_path[0]: # Check if package was found in standard paths
|
||||||
return True, oh_my_zsh_path
|
return True, oh_my_zsh_path[1]
|
||||||
else: # Package wasn't found, try to install it
|
else: # Package wasn't found, try to install it
|
||||||
return InstallationChecks.install_package('oh-my-zsh',
|
return InstallationChecks.install_package('oh-my-zsh',
|
||||||
standard_paths,
|
standard_paths,
|
||||||
|
@ -71,8 +71,9 @@ class InstallationChecks:
|
||||||
zsh_highlight_path = InstallationChecks.get_installation_path(
|
zsh_highlight_path = InstallationChecks.get_installation_path(
|
||||||
standard_paths)
|
standard_paths)
|
||||||
|
|
||||||
if zsh_highlight_path: # Check if package was found in standard paths
|
if zsh_highlight_path[
|
||||||
return True, 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
|
else: # Package wasn't found, try to install it
|
||||||
return InstallationChecks.install_package(
|
return InstallationChecks.install_package(
|
||||||
'zsh-syntax-highlighting', standard_paths,
|
'zsh-syntax-highlighting', standard_paths,
|
||||||
|
@ -226,7 +227,7 @@ class Dotfiles:
|
||||||
return PersonalizedChanges.zshrc(self, file)
|
return PersonalizedChanges.zshrc(self, file)
|
||||||
elif 'vimrc' in file:
|
elif 'vimrc' in file:
|
||||||
return PersonalizedChanges.vimrc(file)
|
return PersonalizedChanges.vimrc(file)
|
||||||
elif 'gitignore' in file:
|
elif '.gitconfig' in file:
|
||||||
return PersonalizedChanges.gitconfig(file)
|
return PersonalizedChanges.gitconfig(file)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
24
util/Path.py
24
util/Path.py
|
@ -14,9 +14,14 @@ def check_dir_exists(paths):
|
||||||
Returns:
|
Returns:
|
||||||
bool -- One of dirs exists/Single dir exists
|
bool -- One of dirs exists/Single dir exists
|
||||||
'''
|
'''
|
||||||
if type(paths) != str:
|
if type(paths) == pathlib.PosixPath:
|
||||||
paths = str(paths)
|
paths = [str(paths)]
|
||||||
paths = paths.split(' ')
|
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:
|
for dir_path in paths:
|
||||||
dir_path = os.path.expanduser(dir_path)
|
dir_path = os.path.expanduser(dir_path)
|
||||||
if os.path.isdir(dir_path):
|
if os.path.isdir(dir_path):
|
||||||
|
@ -35,9 +40,14 @@ def check_file_exists(paths):
|
||||||
Returns:
|
Returns:
|
||||||
bool -- One of files exists/Single file exists
|
bool -- One of files exists/Single file exists
|
||||||
'''
|
'''
|
||||||
if type(paths) != str:
|
if type(paths) == pathlib.PosixPath:
|
||||||
paths = str(paths)
|
paths = [str(paths)]
|
||||||
paths = paths.split(' ')
|
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:
|
for file_path in paths:
|
||||||
file_path = os.path.expanduser(file_path)
|
file_path = os.path.expanduser(file_path)
|
||||||
if os.path.isfile(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:
|
if not absolute_path:
|
||||||
path = pathlib.Path(path).absolute()
|
path = pathlib.Path(path).absolute()
|
||||||
if check_file_exists(path) or file_end:
|
if file_end:
|
||||||
path = get_parent(path)
|
path = get_parent(path)
|
||||||
|
|
||||||
if not check_dir_exists(path)[0]:
|
if not check_dir_exists(path)[0]:
|
||||||
|
|
Loading…
Add table
Reference in a new issue