Skip to content

Commit

Permalink
Replace basestring by six.string_types
Browse files Browse the repository at this point in the history
`basestring` got removed from Python 3. This commit replaces all its
occurrences by `six.string_types`.

See MDAnalysis#643 and MDAnalysis#260
  • Loading branch information
jbarnoud committed Jan 22, 2016
1 parent 848aedf commit 7c56ad2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions package/MDAnalysis/analysis/hole.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- http://www.MDAnalysis.org
# Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein
Expand Down Expand Up @@ -172,8 +172,10 @@
"""

import numpy as np
from six.moves import zip, cPickle
import six

import numpy as np
import glob
import os
import errno
Expand Down Expand Up @@ -1069,7 +1071,7 @@ def _process_orderparameters(self, data):
* If data is a array/list: use as is
* If ``None``: assign frame numbers from trajectory
"""
if isinstance(data, basestring):
if isinstance(data, six.string_types):
q = np.loadtxt(data)
elif data is None:
# frame numbers
Expand Down
6 changes: 4 additions & 2 deletions package/MDAnalysis/coordinates/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- http://www.MDAnalysis.org
# Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein
Expand Down Expand Up @@ -31,6 +31,8 @@
"""

import six

from . import (
_READERS,
_SINGLEFRAME_WRITERS,
Expand Down Expand Up @@ -154,7 +156,7 @@ def get_writer_for(filename=None, format='DCD', multiframe=None):
Added *multiframe* keyword; the default ``None`` reflects the previous
behaviour.
"""
if isinstance(filename, basestring) and filename:
if isinstance(filename, six.string_types) and filename:
root, ext = util.get_ext(filename)
format = util.check_compressed_format(root, ext)
if multiframe is None:
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
__docformat__ = "restructuredtext en"

from six.moves import range
import six

import os
import os.path
Expand Down Expand Up @@ -826,7 +827,7 @@ def guess_format(filename):
def iterable(obj):
"""Returns ``True`` if *obj* can be iterated over and is *not* a string
nor a :class:`NamedStream`"""
if isinstance(obj, (basestring, NamedStream)):
if isinstance(obj, (six.string_types, NamedStream)):
return False # avoid iterating over characters of a string

if hasattr(obj, 'next'):
Expand Down

0 comments on commit 7c56ad2

Please sign in to comment.