How to use the plumbum.lib._setdoc function in plumbum

To help you get started, we’ve selected a few plumbum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomerfiliba / plumbum / plumbum / path / remote.py View on Github external
    @_setdoc(Path)
    def with_suffix(self, suffix, depth=1):
        if (suffix and not suffix.startswith('.') or suffix == '.'):
            raise ValueError("Invalid suffix %r" % (suffix))
        name = self.name
        depth = len(self.suffixes) if depth is None else min(
            depth, len(self.suffixes))
        for i in range(depth):
            name, ext = name.rsplit('.', 1)
        return self.__class__(self.remote, self.dirname) / (name + suffix)
github tomerfiliba / plumbum / plumbum / local_machine.py View on Github external
    @_setdoc(Path)
    def write(self, data):
        with self.open("w") as f:
            f.write(data)
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
    @_setdoc(Path)
    def read(self, encoding=None, mode='r'):
        if encoding and 'b' not in mode:
            mode = mode + 'b'
        with self.open(mode) as f:
            data = f.read()
            if encoding:
                data = data.decode(encoding)
            return data
github tomerfiliba / plumbum / plumbum / machines / paramiko_machine.py View on Github external
    @_setdoc(BaseRemoteMachine)
    def session(self,
                isatty=False,
                term="vt100",
                width=80,
                height=24,
                new_session=False):
        # new_session is ignored for ParamikoMachine
        trans = self._client.get_transport()
        trans.set_keepalive(self._keep_alive)
        chan = trans.open_session()
        if isatty:
            chan.get_pty(term, width, height)
            chan.set_combine_stderr(True)
        chan.invoke_shell()
        stdin = chan.makefile('wb', -1)
        stdout = chan.makefile('rb', -1)
github tomerfiliba / plumbum / plumbum / path / remote.py View on Github external
    @_setdoc(Path)
    def iterdir(self):
        if not self.is_dir():
            return ()
        return (self.join(fn) for fn in self.remote._path_listdir(self))
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
    @_setdoc(Path)
    def is_dir(self):
        return os.path.isdir(str(self))
github tomerfiliba / plumbum / plumbum / machines / ssh_machine.py View on Github external
    @_setdoc(BaseRemoteMachine)
    def upload(self, src, dst):
        if isinstance(src, RemotePath):
            raise TypeError("src of upload cannot be %r" % (src, ))
        if isinstance(dst, LocalPath):
            raise TypeError("dst of upload cannot be %r" % (dst, ))
        if isinstance(dst, RemotePath) and dst.remote != self:
            raise TypeError(
                "dst %r points to a different remote machine" % (dst, ))
        if IS_WIN32:
            src = self._translate_drive_letter(src)
            dst = self._translate_drive_letter(dst)
        self._scp_command(src, "%s:%s" % (self._fqhost, shquote(dst)))
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
    @_setdoc(Path)
    def suffix(self):
        return os.path.splitext(str(self))[1]
github tomerfiliba / plumbum / plumbum / local_machine.py View on Github external
    @_setdoc(Path)
    def dirname(self):
        return LocalPath(os.path.dirname(str(self)))
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
    @_setdoc(Path)
    def is_file(self):
        return os.path.isfile(str(self))