uninstall dst @src: dotfile source path in dotpath @dst: dotfile destination path in the FS @linktype: linktypes.LinkTypes return - True, None : success - False, error_msg : error
(self, src, dst, linktype)
| 37 | self.log = Logger(debug=self.debug) |
| 38 | |
| 39 | def uninstall(self, src, dst, linktype): |
| 40 | """ |
| 41 | uninstall dst |
| 42 | @src: dotfile source path in dotpath |
| 43 | @dst: dotfile destination path in the FS |
| 44 | @linktype: linktypes.LinkTypes |
| 45 | |
| 46 | return |
| 47 | - True, None : success |
| 48 | - False, error_msg : error |
| 49 | """ |
| 50 | if not src or not dst: |
| 51 | self.log.dbg(f'cannot uninstall empty {src} or {dst}') |
| 52 | return True, None |
| 53 | |
| 54 | # ensure exists |
| 55 | path = os.path.expanduser(dst) |
| 56 | path = os.path.normpath(path) |
| 57 | path = path.rstrip(os.sep) |
| 58 | |
| 59 | if not os.path.isfile(path) and not os.path.isdir(path): |
| 60 | msg = f'cannot uninstall special file {path}' |
| 61 | return False, msg |
| 62 | |
| 63 | if not os.path.exists(path): |
| 64 | self.log.dbg(f'cannot uninstall non existing {path}') |
| 65 | return True, None |
| 66 | |
| 67 | msg = f'uninstalling \"{path}\" (link: {linktype})' |
| 68 | self.log.dbg(msg) |
| 69 | ret, msg = self._remove(path) |
| 70 | if ret: |
| 71 | if not self.dry: |
| 72 | self.log.sub(f'uninstall {dst}') |
| 73 | return ret, msg |
| 74 | |
| 75 | def _descend(self, dirpath): |
| 76 | ret = True |