summaryrefslogtreecommitdiffstats
path: root/lib/bb/COW.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-09 19:46:14 -0700
committerChris Larson <chris_larson@mentor.com>2010-04-09 19:46:20 -0700
commitff2e28d0d9723ccd0e9dd635447b6d889cc9f597 (patch)
tree15d8533a7261c5b320fcf4c551c8dc337351c009 /lib/bb/COW.py
parent78f56049ba863b2e585b89db12b32697eb879bbc (diff)
downloadopenembedded-core-contrib-ff2e28d0d9723ccd0e9dd635447b6d889cc9f597.tar.gz
Apply the 2to3 print function transform
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/COW.py')
-rw-r--r--lib/bb/COW.py119
1 files changed, 60 insertions, 59 deletions
diff --git a/lib/bb/COW.py b/lib/bb/COW.py
index 224213db5c..b0afb5fa08 100644
--- a/lib/bb/COW.py
+++ b/lib/bb/COW.py
@@ -23,6 +23,7 @@
# Assign a file to __warn__ to get warnings about slow operations.
#
+from __future__ import print_function
import copy
import types
types.ImmutableTypes = tuple([ \
@@ -77,7 +78,7 @@ class COWDictMeta(COWMeta):
return value
if not cls.__warn__ is False and not isinstance(value, COWMeta):
- print >> cls.__warn__, "Warning: Doing a copy because %s is a mutable type." % key
+ print("Warning: Doing a copy because %s is a mutable type." % key, file=cls.__warn__)
try:
value = value.copy()
except AttributeError, e:
@@ -153,11 +154,11 @@ class COWDictMeta(COWMeta):
return cls.iter("keys")
def itervalues(cls, readonly=False):
if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False:
- print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True."
+ print("Warning: If you arn't going to change any of the values call with True.", file=cls.__warn__)
return cls.iter("values", readonly)
def iteritems(cls, readonly=False):
if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False:
- print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True."
+ print("Warning: If you arn't going to change any of the values call with True.", file=cls.__warn__)
return cls.iter("items", readonly)
class COWSetMeta(COWDictMeta):
@@ -199,120 +200,120 @@ if __name__ == "__main__":
import sys
COWDictBase.__warn__ = sys.stderr
a = COWDictBase()
- print "a", a
+ print("a", a)
a['a'] = 'a'
a['b'] = 'b'
a['dict'] = {}
b = a.copy()
- print "b", b
+ print("b", b)
b['c'] = 'b'
- print
+ print()
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems():
- print x
- print
+ print(x)
+ print()
b['dict']['a'] = 'b'
b['a'] = 'c'
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems():
- print x
- print
+ print(x)
+ print()
try:
b['dict2']
except KeyError, e:
- print "Okay!"
+ print("Okay!")
a['set'] = COWSetBase()
a['set'].add("o1")
a['set'].add("o1")
a['set'].add("o2")
- print "a", a
+ print("a", a)
for x in a['set'].itervalues():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b['set'].itervalues():
- print x
- print
+ print(x)
+ print()
b['set'].add('o3')
- print "a", a
+ print("a", a)
for x in a['set'].itervalues():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b['set'].itervalues():
- print x
- print
+ print(x)
+ print()
a['set2'] = set()
a['set2'].add("o1")
a['set2'].add("o1")
a['set2'].add("o2")
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems(readonly=True):
- print x
- print
+ print(x)
+ print()
del b['b']
try:
- print b['b']
+ print(b['b'])
except KeyError:
- print "Yay! deleted key raises error"
+ print("Yay! deleted key raises error")
if b.has_key('b'):
- print "Boo!"
+ print("Boo!")
else:
- print "Yay - has_key with delete works!"
+ print("Yay - has_key with delete works!")
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems(readonly=True):
- print x
- print
+ print(x)
+ print()
b.__revertitem__('b')
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems(readonly=True):
- print x
- print
+ print(x)
+ print()
b.__revertitem__('dict')
- print "a", a
+ print("a", a)
for x in a.iteritems():
- print x
- print "--"
- print "b", b
+ print(x)
+ print("--")
+ print("b", b)
for x in b.iteritems(readonly=True):
- print x
- print
+ print(x)
+ print()