from __future__ import print_function
import copy
import types
-types.ImmutableTypes = tuple([ \
- types.BooleanType, \
- types.ComplexType, \
- types.FloatType, \
- types.IntType, \
- types.LongType, \
- types.NoneType, \
- types.TupleType, \
- frozenset] + \
- list(types.StringTypes))
+ImmutableTypes = (
+ types.NoneType,
+ bool,
+ complex,
+ float,
+ int,
+ long,
+ tuple,
+ frozenset,
+ basestring
+)
MUTABLE = "__mutable__"
__call__ = cow
def __setitem__(cls, key, value):
- if not isinstance(value, types.ImmutableTypes):
+ if not isinstance(value, ImmutableTypes):
if not isinstance(value, COWMeta):
cls.__hasmutable__ = True
key += MUTABLE
#
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
-import sys, os, re, types
+import sys, os, re
if sys.argv[0][-5:] == "pydoc":
path = os.path.dirname(os.path.dirname(sys.argv[1]))
else:
if all:
o.write('# %s=%s\n' % (var, oval))
- if not isinstance(val, types.StringType):
+ if not isinstance(val, basestring):
return 0
if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
-import copy, re, sys, types
+import copy, re, sys
import bb
from bb import utils
from bb.COW import COWDictBase
code = match.group()[3:-1]
codeobj = compile(code.strip(), varname or "<expansion>", "eval")
s = utils.better_eval(codeobj, {"d": self})
- if isinstance(s, types.IntType): s = str(s)
+ if isinstance(s, int): s = str(s)
return s
- if not isinstance(s, types.StringType): # sanity check
+ if not isinstance(s, basestring): # sanity check
return s
if varname and varname in self.expand_cache:
s = __expand_var_regexp__.sub(var_sub, s)
s = __expand_python_regexp__.sub(python_sub, s)
if s == olds: break
- if not isinstance(s, types.StringType): # sanity check
+ if not isinstance(s, basestring): # sanity check
bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s))
except KeyboardInterrupt:
raise
for i in uri_find_decoded:
loc = uri_find_decoded.index(i)
result_decoded[loc] = uri_decoded[loc]
- import types
- if type(i) == types.StringType:
+ if isinstance(i, basestring):
if (re.match(i, uri_decoded[loc])):
result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
if uri_find_decoded.index(i) == 2:
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import re, fcntl, os, types, string, stat, shutil, time
+import re, fcntl, os, string, stat, shutil, time
import sys
import bb
import errno
if ca == None and cb == None:
return 0
- if isinstance(ca, types.StringType):
+ if isinstance(ca, basestring):
sa = ca in separators
- if isinstance(cb, types.StringType):
+ if isinstance(cb, basestring):
sb = cb in separators
if sa and not sb:
return -1