How to use the plumbum.path.local.LocalPath 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 / local.py View on Github external
def __new__(cls, *parts):
        if len(parts) == 1 and \
                isinstance(parts[0], cls) and \
                not isinstance(parts[0], LocalWorkdir):
            return parts[0]
        if not parts:
            raise TypeError("At least one path part is required (none given)")
        if any(isinstance(path, RemotePath) for path in parts):
            raise TypeError(
                "LocalPath cannot be constructed from %r" % (parts, ))
        self = super(LocalPath, cls).__new__(
            cls, os.path.normpath(os.path.join(*(str(p) for p in parts))))
        return self
github tomerfiliba / plumbum / plumbum / machines / paramiko_machine.py View on Github external
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,))
        return self._upload(src if isinstance(src, LocalPath) else LocalPath(src),
            dst if isinstance(dst, RemotePath) else self.path(dst))
github tomerfiliba / plumbum / plumbum / machines / local.py View on Github external
def __init__(self):
        # os.environ already takes care of upper'ing on windows
        self._curr = os.environ.copy()
        BaseEnv.__init__(self, LocalPath, os.path.pathsep)
        if IS_WIN32 and "HOME" not in self and self.home is not None:
            self["HOME"] = self.home
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
        fn = lambda pat: [LocalPath(m) for m in glob.glob(str(self / pat))]
        return self._glob(pattern, fn)
github tomerfiliba / plumbum / plumbum / machines / paramiko_machine.py View on Github external
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, ))
        return self._upload(
            src if isinstance(src, LocalPath) else LocalPath(src), dst
            if isinstance(dst, RemotePath) else self.path(dst))
github tomerfiliba / plumbum / plumbum / machines / local.py View on Github external
def path(self, *parts):
        """A factory for :class:`LocalPaths `.
        Usage: ``p = local.path("/usr", "lib", "python2.7")``
        """
        parts2 = [str(self.cwd)]
        for p in parts:
            if isinstance(p, RemotePath):
                raise TypeError("Cannot construct LocalPath from %r" % (p, ))
            parts2.append(self.env.expanduser(str(p)))
        return LocalPath(os.path.join(*parts2))
github tomerfiliba / plumbum / plumbum / path / local.py View on Github external
def with_name(self, name):
        return LocalPath(self.dirname) / name
github tomerfiliba / plumbum / plumbum / machines / paramiko_machine.py View on Github external
def download(self, src, dst):
        if isinstance(src, LocalPath):
            raise TypeError("src of download cannot be %r" % (src,))
        if isinstance(src, RemotePath) and src.remote != self:
            raise TypeError("src %r points to a different remote machine" % (src,))
        if isinstance(dst, RemotePath):
            raise TypeError("dst of download cannot be %r" % (dst,))
        return self._download(src if isinstance(src, RemotePath) else self.path(src),
            dst if isinstance(dst, LocalPath) else LocalPath(dst))