MCPcopy
hub / github.com/deadc0de6/dotdrop / _remove

Method _remove

dotdrop/uninstaller.py:108–132  ·  view source on GitHub ↗

remove path

(self, path)

Source from the content-addressed store, hash-verified

106 return True, ''
107
108 def _remove(self, path):
109 """remove path"""
110 self.log.dbg(f'handling uninstall of {path}')
111 if path.endswith(self.backup_suffix):
112 self.log.dbg(f'skip {path} ignored')
113 return True, ''
114 backup = f'{path}{self.backup_suffix}'
115 if os.path.exists(backup):
116 self.log.dbg(f'backup exists for {path}: {backup}')
117 return self._replace(path, backup)
118 self.log.dbg(f'no backup file for {path}')
119
120 if os.path.isdir(path):
121 self.log.dbg(f'{path} is a directory')
122 return self._descend(path)
123
124 if self.dry:
125 self.log.dry(f'would \"rm {path}\"')
126 return True, ''
127
128 msg = f'Remove {path}?'
129 if self.safe and not self.log.ask(msg):
130 return False, 'user refused'
131 self.log.dbg(f'removing {path}')
132 return self._remove_path(path)
133
134 def _replace(self, path, backup):
135 """replace path by backup"""

Callers 2

uninstallMethod · 0.95
_descendMethod · 0.95

Calls 6

_replaceMethod · 0.95
_descendMethod · 0.95
_remove_pathMethod · 0.95
dbgMethod · 0.80
dryMethod · 0.80
askMethod · 0.80

Tested by

no test coverage detected