[gobject-introspection] giscanner: use dict.items()...



commit a867ab49295f5f6f1f72042c237625905e43953f
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Wed Nov 28 19:05:07 2012 +0100

    giscanner: use dict.items()...
    
    ... in favor of "for key in dict: value=dict[key]"
    and "dict.iteritems()". This makes it possible to
    run the upcoming annotationparser.py tests with both
    Python 2 and Python 3.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688897

 giscanner/annotationparser.py |   11 +++++------
 giscanner/maintransformer.py  |    2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d498913..9770480 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -250,7 +250,7 @@ class DocTag(object):
         if value is None:
             return
 
-        for name, v in value.all().iteritems():
+        for name, v in value.all().items():
             if name in [OPT_ARRAY_ZERO_TERMINATED, OPT_ARRAY_FIXED_SIZE]:
                 try:
                     int(v)
@@ -318,12 +318,12 @@ class DocTag(object):
             if value:
                 if type(value) != str:
                     value = ' '.join((serialize_one(k, v, '%s=%s', '%s')
-                                      for k, v in value.all().iteritems()))
+                                      for k, v in value.all().items()))
                 return fmt % (option, value)
             else:
                 return fmt2 % (option, )
         annotations = []
-        for option, value in self.options.iteritems():
+        for option, value in self.options.items():
             annotations.append(
                 serialize_one(option, value, '(%s %s)', '(%s)'))
         if annotations:
@@ -345,8 +345,7 @@ class DocTag(object):
             # validation below is most certainly going to fail.
             return
 
-        for option in self.options:
-            value = self.options[option]
+        for option, value in self.options.items():
             if option == OPT_ALLOW_NONE:
                 self._validate_option(option, value, n_params=0)
             elif option == OPT_ARRAY:
@@ -429,7 +428,7 @@ class DocOptions(object):
             if key == item:
                 yield value
 
-    def iteritems(self):
+    def items(self):
         return iter(self.values)
 
 
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 037cb26..4ad800d 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -631,7 +631,7 @@ usage is void (*_gtk_reserved1)(void);"""
 
         annos_tag = block.get_tag(TAG_ATTRIBUTES)
         if annos_tag is not None:
-            for key, value in annos_tag.options.iteritems():
+            for key, value in annos_tag.options.items():
                 if value:
                     node.attributes.append((key, value.one()))
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]