mirror of
1
0
Fork 0

normalise paths for windows compat

This commit is contained in:
Matt Richards 2021-02-14 18:21:16 +10:00
parent 4ec846cdad
commit e985d310e2
2 changed files with 6 additions and 4 deletions

View File

@ -38,11 +38,13 @@ class Clean(dotbot.Plugin):
Cleans all the broken symbolic links in target if they point to
a subdirectory of the base directory or if forced to clean.
'''
if not os.path.isdir(os.path.expandvars(os.path.expanduser(target))):
target_normalised = os.path.normpath(os.path.expandvars(os.path.expanduser(target)))
isdir = os.path.isdir(target_normalised)
if isdir is False:
self._log.debug('Ignoring nonexistent directory %s' % target)
return True
for item in os.listdir(os.path.expandvars(os.path.expanduser(target))):
path = os.path.join(os.path.expandvars(os.path.expanduser(target)), item)
for item in os.listdir(target_normalised):
path = os.path.join(target_normalised, item)
if recursive and os.path.isdir(path):
# isdir implies not islink -- we don't want to descend into
# symlinked directories. okay to do a recursive call here

View File

@ -20,7 +20,7 @@ class Create(dotbot.Plugin):
def _process_paths(self, paths):
success = True
for path in paths:
path = os.path.expandvars(os.path.expanduser(path))
path = os.path.normpath(os.path.expandvars(os.path.expanduser(path)))
success &= self._create(path)
if success:
self._log.info('All paths have been set up')