MCPcopy
hub / github.com/Gallopsled/pwntools / replace

Method replace

pwnlib/filesystem/ssh.py:663–680  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

resFunction · 0.45
make_functionFunction · 0.45
templatesMethod · 0.45
prettyMethod · 0.45
__getattr__Method · 0.45
putFunction · 0.45
__init__Method · 0.45
load_constants.pyFile · 0.45
generate_darwin.pyFile · 0.45
encodeFunction · 0.45
__call__Method · 0.45
__init__Method · 0.45

Calls 3

_newMethod · 0.95
renameMethod · 0.95
unlinkMethod · 0.45

Tested by

no test coverage detected