summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-12 08:14:11 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:33 +0100
commit22a21799059b156d8858cbf32acb7c2aefb9a23b (patch)
tree1e0e83c86fe04e30576ddfb34577940596f8d809
parent1180bab54e2879401f3586c91a48174191a1ee8b (diff)
downloadpoky-22a21799059b156d8858cbf32acb7c2aefb9a23b.tar.gz
Kill unnecessary usages of the types module
types.IntType -> int types.StringType -> basestring ... Also moves our ImmutableTypes tuple into our own namespace. (Bitbake rev: 83674a3a5564ecb1f9d2c9b2d5b1eeb3c31272ab) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/COW.py23
-rw-r--r--bitbake/lib/bb/data.py4
-rw-r--r--bitbake/lib/bb/data_smart.py8
-rw-r--r--bitbake/lib/bb/fetch/__init__.py3
-rw-r--r--bitbake/lib/bb/utils.py6
5 files changed, 22 insertions, 22 deletions
diff --git a/bitbake/lib/bb/COW.py b/bitbake/lib/bb/COW.py
index ccb7cde3ba..23a2cae2b4 100644
--- a/bitbake/lib/bb/COW.py
+++ b/bitbake/lib/bb/COW.py
@@ -26,16 +26,17 @@
26from __future__ import print_function 26from __future__ import print_function
27import copy 27import copy
28import types 28import types
29types.ImmutableTypes = tuple([ \ 29ImmutableTypes = (
30 types.BooleanType, \ 30 types.NoneType,
31 types.ComplexType, \ 31 bool,
32 types.FloatType, \ 32 complex,
33 types.IntType, \ 33 float,
34 types.LongType, \ 34 int,
35 types.NoneType, \ 35 long,
36 types.TupleType, \ 36 tuple,
37 frozenset] + \ 37 frozenset,
38 list(types.StringTypes)) 38 basestring
39)
39 40
40MUTABLE = "__mutable__" 41MUTABLE = "__mutable__"
41 42
@@ -60,7 +61,7 @@ class COWDictMeta(COWMeta):
60 __call__ = cow 61 __call__ = cow
61 62
62 def __setitem__(cls, key, value): 63 def __setitem__(cls, key, value):
63 if not isinstance(value, types.ImmutableTypes): 64 if not isinstance(value, ImmutableTypes):
64 if not isinstance(value, COWMeta): 65 if not isinstance(value, COWMeta):
65 cls.__hasmutable__ = True 66 cls.__hasmutable__ = True
66 key += MUTABLE 67 key += MUTABLE
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index e401c53429..ba496c9d93 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -37,7 +37,7 @@ the speed is more critical here.
37# 37#
38#Based on functions from the base bb module, Copyright 2003 Holger Schurig 38#Based on functions from the base bb module, Copyright 2003 Holger Schurig
39 39
40import sys, os, re, types 40import sys, os, re
41if sys.argv[0][-5:] == "pydoc": 41if sys.argv[0][-5:] == "pydoc":
42 path = os.path.dirname(os.path.dirname(sys.argv[1])) 42 path = os.path.dirname(os.path.dirname(sys.argv[1]))
43else: 43else:
@@ -193,7 +193,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
193 if all: 193 if all:
194 o.write('# %s=%s\n' % (var, oval)) 194 o.write('# %s=%s\n' % (var, oval))
195 195
196 if not isinstance(val, types.StringType): 196 if not isinstance(val, basestring):
197 return 0 197 return 0
198 198
199 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: 199 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 1704ed631c..9436023b30 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -28,7 +28,7 @@ BitBake build tools.
28# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 28# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29# Based on functions from the base bb module, Copyright 2003 Holger Schurig 29# Based on functions from the base bb module, Copyright 2003 Holger Schurig
30 30
31import copy, re, sys, types 31import copy, re, sys
32import bb 32import bb
33from bb import utils 33from bb import utils
34from bb.COW import COWDictBase 34from bb.COW import COWDictBase
@@ -66,10 +66,10 @@ class DataSmart:
66 code = match.group()[3:-1] 66 code = match.group()[3:-1]
67 codeobj = compile(code.strip(), varname or "<expansion>", "eval") 67 codeobj = compile(code.strip(), varname or "<expansion>", "eval")
68 s = utils.better_eval(codeobj, {"d": self}) 68 s = utils.better_eval(codeobj, {"d": self})
69 if isinstance(s, types.IntType): s = str(s) 69 if isinstance(s, int): s = str(s)
70 return s 70 return s
71 71
72 if not isinstance(s, types.StringType): # sanity check 72 if not isinstance(s, basestring): # sanity check
73 return s 73 return s
74 74
75 if varname and varname in self.expand_cache: 75 if varname and varname in self.expand_cache:
@@ -81,7 +81,7 @@ class DataSmart:
81 s = __expand_var_regexp__.sub(var_sub, s) 81 s = __expand_var_regexp__.sub(var_sub, s)
82 s = __expand_python_regexp__.sub(python_sub, s) 82 s = __expand_python_regexp__.sub(python_sub, s)
83 if s == olds: break 83 if s == olds: break
84 if not isinstance(s, types.StringType): # sanity check 84 if not isinstance(s, basestring): # sanity check
85 bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s)) 85 bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s))
86 except KeyboardInterrupt: 86 except KeyboardInterrupt:
87 raise 87 raise
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index fec9c6ed79..f52b0acfc7 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -126,8 +126,7 @@ def uri_replace(uri, uri_find, uri_replace, d):
126 for i in uri_find_decoded: 126 for i in uri_find_decoded:
127 loc = uri_find_decoded.index(i) 127 loc = uri_find_decoded.index(i)
128 result_decoded[loc] = uri_decoded[loc] 128 result_decoded[loc] = uri_decoded[loc]
129 import types 129 if isinstance(i, basestring):
130 if type(i) == types.StringType:
131 if (re.match(i, uri_decoded[loc])): 130 if (re.match(i, uri_decoded[loc])):
132 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) 131 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
133 if uri_find_decoded.index(i) == 2: 132 if uri_find_decoded.index(i) == 2:
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 02668b16c4..a7fb44d7d2 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -19,7 +19,7 @@ BitBake Utility Functions
19# with this program; if not, write to the Free Software Foundation, Inc., 19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 21
22import re, fcntl, os, types, string, stat, shutil, time 22import re, fcntl, os, string, stat, shutil, time
23import sys 23import sys
24import bb 24import bb
25import errno 25import errno
@@ -72,9 +72,9 @@ def vercmp_part(a, b):
72 if ca == None and cb == None: 72 if ca == None and cb == None:
73 return 0 73 return 0
74 74
75 if isinstance(ca, types.StringType): 75 if isinstance(ca, basestring):
76 sa = ca in separators 76 sa = ca in separators
77 if isinstance(cb, types.StringType): 77 if isinstance(cb, basestring):
78 sb = cb in separators 78 sb = cb in separators
79 if sa and not sb: 79 if sa and not sb:
80 return -1 80 return -1