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

Method _replace

dotdrop/uninstaller.py:134–150  ·  view source on GitHub ↗

replace path by backup

(self, path, backup)

Source from the content-addressed store, hash-verified

132 return self._remove_path(path)
133
134 def _replace(self, path, backup):
135 """replace path by backup"""
136 if self.dry:
137 self.log.dry(f'would \"mv {backup} {path}\"')
138 return True, ''
139
140 msg = f'Restore {path} from {backup}?'
141 if self.safe and not self.log.ask(msg):
142 return False, 'user refused'
143
144 try:
145 self.log.dbg(f'mv {backup} {path}')
146 os.replace(backup, path)
147 except OSError as exc:
148 err = f'replacing \"{path}\" by \"{backup}\" failed: {exc}'
149 return False, err
150 return True, ''

Callers 1

_removeMethod · 0.95

Calls 3

dryMethod · 0.80
askMethod · 0.80
dbgMethod · 0.80

Tested by

no test coverage detected