diff --git a/plumbum/cli.py b/plumbum/cli.py index 5112c7613..38f7f2c01 100644 --- a/plumbum/cli.py +++ b/plumbum/cli.py @@ -126,7 +126,7 @@ def set_terse(self): :returns: The decorated function (with a ``_switch_info`` attribute) """ - if isinstance(names, basestring): + if isinstance(names, six.string_types): names = [names] names = [n.lstrip("-") for n in names] requires = [n.lstrip("-") for n in requires] diff --git a/plumbum/commands.py b/plumbum/commands.py index 5a5ca3905..3b614a32a 100644 --- a/plumbum/commands.py +++ b/plumbum/commands.py @@ -292,7 +292,7 @@ def _get_encoding(self): def formulate(self, level = 0, args = ()): return self.cmd.formulate(level + 1, self.args + tuple(args)) def popen(self, args = (), **kwargs): - if isinstance(args, basestring): + if isinstance(args, six.string_types): args = (args,) return self.cmd.popen(self.args + tuple(args), **kwargs) @@ -345,7 +345,7 @@ def popen(self, args = (), **kwargs): if self.KWARG in kwargs and kwargs[self.KWARG] not in (PIPE, None): raise RedirectionError("%s is already redirected" % (self.KWARG,)) - if isinstance(self.file, (basestring, LocalPath)): + if isinstance(self.file, six.string_types + (LocalPath,)): f = kwargs[self.KWARG] = open(str(self.file), self.MODE) elif isinstance(self.file, RemotePath): raise TypeError("Cannot redirect to/from remote paths") diff --git a/plumbum/local_machine.py b/plumbum/local_machine.py index a1487a1c6..2afd62c77 100644 --- a/plumbum/local_machine.py +++ b/plumbum/local_machine.py @@ -8,6 +8,7 @@ import stat import time import platform +import six from tempfile import mkdtemp from subprocess import Popen, PIPE from contextlib import contextmanager @@ -421,7 +422,7 @@ def __repr__(self): return "LocalCommand(%r)" % (self.executable,) def popen(self, args = (), cwd = None, env = None, **kwargs): - if isinstance(args, basestring): + if isinstance(args, six.string_types): args = (args,) return local._popen(self.executable, self.formulate(0, args), cwd = self.cwd if cwd is None else cwd, env = self.env if env is None else env, diff --git a/plumbum/remote_path.py b/plumbum/remote_path.py index 2ca1a2e55..8b72c0911 100644 --- a/plumbum/remote_path.py +++ b/plumbum/remote_path.py @@ -138,7 +138,7 @@ def delete(self): def move(self, dst): if isinstance(dst, RemotePath) and dst.remote is not self.remote: raise TypeError("dst points to a different remote machine") - elif not isinstance(dst, basestring): + elif not isinstance(dst, six.string_types): raise TypeError("dst must be a string or a RemotePath (to the same remote machine)") self.remote._session.run("mv %s %s" % (shquote(self), shquote(dst))) @@ -147,10 +147,10 @@ def copy(self, dst, override = False): if isinstance(dst, RemotePath): if dst.remote is not self.remote: raise TypeError("dst points to a different remote machine") - elif not isinstance(dst, basestring): + elif not isinstance(dst, six.string_types): raise TypeError("dst must be a string or a RemotePath (to the same remote machine)", repr(dst)) if override: - if isinstance(dst, basestring): + if isinstance(dst, six.string_types): dst = RemotePath(self.remote, dst) dst.remove() self.remote._session.run("cp -r %s %s" % (shquote(self), shquote(dst))) diff --git a/plumbum/utils.py b/plumbum/utils.py index 4b7d47cba..d121ae951 100644 --- a/plumbum/utils.py +++ b/plumbum/utils.py @@ -1,4 +1,5 @@ from __future__ import with_statement +import six from plumbum.path import Path from plumbum.local_machine import local, LocalPath @@ -11,7 +12,7 @@ def delete(*paths): for p in paths: if isinstance(p, Path): p.delete() - elif isinstance(p, basestring): + elif isinstance(p, six.string_types): local.path(p).delete() elif hasattr(p, "__iter__"): delete(*p)