]> code.ossystems Code Review - openembedded-core.git/commitdiff
Kill unnecessary usages of the types module
authorChris Larson <chris_larson@mentor.com>
Mon, 12 Apr 2010 15:14:11 +0000 (08:14 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 2 Jul 2010 14:41:33 +0000 (15:41 +0100)
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>
bitbake/lib/bb/COW.py
bitbake/lib/bb/data.py
bitbake/lib/bb/data_smart.py
bitbake/lib/bb/fetch/__init__.py
bitbake/lib/bb/utils.py

index ccb7cde3ba760d244e3916b48d372553e524f50f..23a2cae2b43a1fe6c9916bfbe0d097da3400a938 100644 (file)
 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__"
 
@@ -60,7 +61,7 @@ class COWDictMeta(COWMeta):
     __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
index e401c53429e32b4cb007eb3a59957ba8d5c8c34c..ba496c9d93a493329a0208ae38c87ade6f13d39d 100644 (file)
@@ -37,7 +37,7 @@ the speed is more critical here.
 #
 #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:
@@ -193,7 +193,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
     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:
index 1704ed631ca6ccee4492ce56ca455e58f0223c86..9436023b30933ed4c9fc044a58404bba085e1fa3 100644 (file)
@@ -28,7 +28,7 @@ BitBake build tools.
 # 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
@@ -66,10 +66,10 @@ class DataSmart:
             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:
@@ -81,7 +81,7 @@ class DataSmart:
                 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
index fec9c6ed79538e5fc68a3d0ecabdf1e4ada4c9c4..f52b0acfc799963ff4dbc570532aefff493313d6 100644 (file)
@@ -126,8 +126,7 @@ def uri_replace(uri, uri_find, uri_replace, d):
     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:
index 02668b16c4e95b577b1322651dcc2362bfbb4f6a..a7fb44d7d2f212668631c0eba88b868dc0e3e920 100644 (file)
@@ -19,7 +19,7 @@ BitBake Utility Functions
 # 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
@@ -72,9 +72,9 @@ def vercmp_part(a, b):
         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