1
0
Fork 0
mirror of synced 2024-06-15 21:51:10 -04:00

removed unnecessary _dispatch_targets method; fixed docstring; fixed not removed message

This commit is contained in:
dein0s 2017-03-26 18:10:05 +03:00
parent 2303303eea
commit 3302e917a4

View file

@ -19,7 +19,7 @@ class Clean(dotbot.Plugin):
success = True success = True
defaults = self._context.defaults().get(self._directive, {}) defaults = self._context.defaults().get(self._directive, {})
force = defaults.get('force', False) force = defaults.get('force', False)
for target in self._dispatch_targets(targets): for target in targets:
if isinstance(targets, dict): if isinstance(targets, dict):
force = targets[target].get('force', force) force = targets[target].get('force', force)
success &= self._clean(target, force) success &= self._clean(target, force)
@ -31,8 +31,8 @@ class Clean(dotbot.Plugin):
def _clean(self, target, force): def _clean(self, target, force):
''' '''
Cleans all the broken symbolic links in target if that point to Cleans all the broken symbolic links in target if they point to
a subdirectory of the base directory or forced to clean. a subdirectory of the base directory or if forced to clean.
''' '''
if not os.path.isdir(os.path.expanduser(target)): if not os.path.isdir(os.path.expanduser(target)):
self._log.debug('Ignoring nonexistent directory %s' % target) self._log.debug('Ignoring nonexistent directory %s' % target)
@ -45,19 +45,9 @@ class Clean(dotbot.Plugin):
self._log.lowinfo('Removing invalid link %s -> %s' % (path, points_at)) self._log.lowinfo('Removing invalid link %s -> %s' % (path, points_at))
os.remove(path) os.remove(path)
else: else:
self._log.lowinfo('Link %s -> %s not removed (force=%s). '\ self._log.lowinfo('Link %s -> %s not removed.' % (path, points_at))
'You can remove it manually.' % (path, points_at, force))
return True return True
def _dispatch_targets(self, targets):
'''
Returns list of targets to process.
'''
if isinstance(targets, list):
return targets
if isinstance(targets, dict):
return targets.keys()
def _in_directory(self, path, directory): def _in_directory(self, path, directory):
''' '''
Returns true if the path is in the directory. Returns true if the path is in the directory.