[gobject-introspection/wip/docs: 9/11] annotationparser: Remove get_tag/get_param



commit 9af9e25308671ded2cbae5fa24574e1fd06e630a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Mar 27 17:33:52 2013 -0400

    annotationparser: Remove get_tag/get_param
    
    They're useless if we can just access the dict directly.

 giscanner/annotationparser.py   |    6 ------
 giscanner/introspectablepass.py |    2 +-
 giscanner/maintransformer.py    |   34 +++++++++++++++++-----------------
 3 files changed, 18 insertions(+), 24 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 9c0ce5a..dd19dbd 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -378,12 +378,6 @@ class DocBlock(object):
     def __repr__(self):
         return '<DocBlock %r %r>' % (self.name, self.options)
 
-    def get_tag(self, name):
-        return self.tags.get(name)
-
-    def get_param(self, name):
-        return self.params.get(name)
-
     def to_gtk_doc(self):
         options = ''
         if self.options:
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 460c820..3e29539 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -58,7 +58,7 @@ class IntrospectablePass(object):
         else:
             context = "return value: "
             if block:
-                return_tag = block.get_tag(TAG_RETURNS)
+                return_tag = block.tags.get(TAG_RETURNS)
                 if return_tag:
                     position = return_tag.position
         message.warn_node(parent, prefix + context + text,
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 049ba9b..c08f9fb 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -142,7 +142,7 @@ usage is void (*_gtk_reserved1)(void);"""
     def _apply_annotation_rename_to(self, node, chain, block):
         if not block:
             return
-        rename_to = block.get_tag(TAG_RENAME_TO)
+        rename_to = block.tags.get(TAG_RENAME_TO)
         if not rename_to:
             return
         rename_to = rename_to.value
@@ -234,13 +234,13 @@ usage is void (*_gtk_reserved1)(void);"""
         if isinstance(node, ast.Class):
             block = self._get_block(node)
             if block:
-                tag = block.get_tag(TAG_UNREF_FUNC)
+                tag = block.tags.get(TAG_UNREF_FUNC)
                 node.unref_func = tag.value if tag else None
-                tag = block.get_tag(TAG_REF_FUNC)
+                tag = block.tags.get(TAG_REF_FUNC)
                 node.ref_func = tag.value if tag else None
-                tag = block.get_tag(TAG_SET_VALUE_FUNC)
+                tag = block.tags.get(TAG_SET_VALUE_FUNC)
                 node.set_value_func = tag.value if tag else None
-                tag = block.get_tag(TAG_GET_VALUE_FUNC)
+                tag = block.tags.get(TAG_GET_VALUE_FUNC)
                 node.get_value_func = tag.value if tag else None
         if isinstance(node, ast.Constant):
             self._apply_annotations_constant(node)
@@ -602,11 +602,11 @@ usage is void (*_gtk_reserved1)(void);"""
 
         node.doc = block.comment if block.comment else ''
 
-        since_tag = block.get_tag(TAG_SINCE)
+        since_tag = block.tags.get(TAG_SINCE)
         if since_tag is not None:
             node.version = since_tag.value
 
-        deprecated_tag = block.get_tag(TAG_DEPRECATED)
+        deprecated_tag = block.tags.get(TAG_DEPRECATED)
         if deprecated_tag is not None:
             value = deprecated_tag.value
             if ': ' in value:
@@ -620,7 +620,7 @@ usage is void (*_gtk_reserved1)(void);"""
             if version is not None:
                 node.deprecated_version = version
 
-        stability_tag = block.get_tag(TAG_STABILITY)
+        stability_tag = block.tags.get(TAG_STABILITY)
         if stability_tag is not None:
             stability = stability_tag.value.capitalize()
             if stability in ["Stable", "Unstable", "Private", "Internal"]:
@@ -629,7 +629,7 @@ usage is void (*_gtk_reserved1)(void);"""
                 message.warn('unknown value "%s" for Stability tag' % (
                     stability_tag.value), stability_tag.position)
 
-        annos_tag = block.get_tag(TAG_ATTRIBUTES)
+        annos_tag = block.tags.get(TAG_ATTRIBUTES)
         if annos_tag is not None:
             for key, value in annos_tag.options.items():
                 if value:
@@ -691,7 +691,7 @@ usage is void (*_gtk_reserved1)(void);"""
 
     def _apply_annotations_return(self, parent, return_, block):
         if block:
-            tag = block.get_tag(TAG_RETURNS)
+            tag = block.tags.get(TAG_RETURNS)
         else:
             tag = None
         self._apply_annotations_param_ret_common(parent, return_, tag)
@@ -702,7 +702,7 @@ usage is void (*_gtk_reserved1)(void);"""
             declparams.add(parent.instance_parameter.argname)
         for param in params:
             if block:
-                tag = block.get_param(param.argname)
+                tag = block.params.get(param.argname)
             else:
                 tag = None
             self._apply_annotations_param(parent, param, tag)
@@ -728,7 +728,7 @@ usage is void (*_gtk_reserved1)(void);"""
                 text = ', should be one of %s' % (
                 ', '.join(repr(p) for p in unused), )
 
-            tag = block.get_param(doc_name)
+            tag = block.params.get(doc_name)
             message.warn(
                 '%s: unknown parameter %r in documentation comment%s' % (
                 block.name, doc_name, text),
@@ -756,7 +756,7 @@ usage is void (*_gtk_reserved1)(void);"""
     def _apply_annotations_field(self, parent, block, field):
         if not block:
             return
-        tag = block.get_param(field.name)
+        tag = block.params.get(field.name)
         if not tag:
             return
         t = tag.options.get(OPT_TYPE)
@@ -774,7 +774,7 @@ usage is void (*_gtk_reserved1)(void);"""
         self._apply_annotations_annotated(prop, block)
         if not block:
             return
-        transfer_tag = block.get_tag(TAG_TRANSFER)
+        transfer_tag = block.tags.get(TAG_TRANSFER)
         if transfer_tag is not None:
             transfer = transfer_tag.value
             if transfer == OPT_TRANSFER_FLOATING:
@@ -782,7 +782,7 @@ usage is void (*_gtk_reserved1)(void);"""
             prop.transfer = transfer
         else:
             prop.transfer = self._get_transfer_default(parent, prop)
-        type_tag = block.get_tag(TAG_TYPE)
+        type_tag = block.tags.get(TAG_TYPE)
         if type_tag:
             prop.type = self._resolve_toplevel(type_tag.value, prop.type, prop, parent)
 
@@ -821,7 +821,7 @@ usage is void (*_gtk_reserved1)(void);"""
 
         self._apply_annotations_annotated(node, block)
 
-        tag = block.get_tag(TAG_VALUE)
+        tag = block.tags.get(TAG_VALUE)
         if tag:
             node.value = tag.value
 
@@ -848,7 +848,7 @@ usage is void (*_gtk_reserved1)(void);"""
         parent = chain[-1] if chain else None
         if not (block and parent):
             return
-        virtual = block.get_tag(TAG_VFUNC)
+        virtual = block.tags.get(TAG_VFUNC)
         if not virtual:
             return
         invoker_name = virtual.value


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