Replace target file with file at this path Example: >>> a = SSHPath('rename_from', ssh=ssh_conn) >>> a.write_text('A') >>> b = SSHPath('rename_to', ssh=ssh_conn) >>> b.write_text('B') >>> a.replace(b) >>> b.read_text()
(self, target)
| 661 | self.ssh.sftp.rename(self.path, target) |
| 662 | |
| 663 | def replace(self, target): |
| 664 | """Replace target file with file at this path |
| 665 | |
| 666 | Example: |
| 667 | |
| 668 | >>> a = SSHPath('rename_from', ssh=ssh_conn) |
| 669 | >>> a.write_text('A') |
| 670 | >>> b = SSHPath('rename_to', ssh=ssh_conn) |
| 671 | >>> b.write_text('B') |
| 672 | >>> a.replace(b) |
| 673 | >>> b.read_text() |
| 674 | 'A' |
| 675 | """ |
| 676 | if isinstance(target, SSHPath): |
| 677 | target = target.path |
| 678 | |
| 679 | self._new(target).unlink(missing_ok=True) |
| 680 | self.rename(target) |
| 681 | |
| 682 | def exists(self): |
| 683 | """Returns True if the path exists |
no test coverage detected