From e985d310e281c5bd12e8ea4e8436b10526811f5a Mon Sep 17 00:00:00 2001 From: Matt Richards Date: Sun, 14 Feb 2021 18:21:16 +1000 Subject: [PATCH] normalise paths for windows compat --- dotbot/plugins/clean.py | 8 +++++--- dotbot/plugins/create.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dotbot/plugins/clean.py b/dotbot/plugins/clean.py index 09b11d8..052b090 100644 --- a/dotbot/plugins/clean.py +++ b/dotbot/plugins/clean.py @@ -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 diff --git a/dotbot/plugins/create.py b/dotbot/plugins/create.py index 015645a..144c1c4 100644 --- a/dotbot/plugins/create.py +++ b/dotbot/plugins/create.py @@ -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')