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>
This commit is contained in:
parent
1180bab54e
commit
22a2179905
|
@ -26,16 +26,17 @@
|
|||
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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue