Skip to content

Commit

Permalink
change basestring to six.string_types; closes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerfiliba committed Oct 10, 2012
1 parent fec1bac commit cb5cece
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plumbum/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions plumbum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion plumbum/local_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions plumbum/remote_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand All @@ -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)))
Expand Down
3 changes: 2 additions & 1 deletion plumbum/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import with_statement
import six
from plumbum.path import Path
from plumbum.local_machine import local, LocalPath

Expand All @@ -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)
Expand Down

0 comments on commit cb5cece

Please sign in to comment.