From a0185528a17378b6e6e7bc458f34b1f3719cc420 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 27 Mar 2013 17:33:52 -0400 Subject: annotationparser: Remove get_tag/get_param They're useless if we can just access the dict directly. https://bugzilla.gnome.org/show_bug.cgi?id=688897 --- 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 ef9cd31d..c0b439a1 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -378,12 +378,6 @@ class DocBlock(object): def __repr__(self): return '' % (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 460c8200..3e295391 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 d2a8be7b..28ffed36 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -135,7 +135,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 @@ -227,13 +227,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) @@ -595,11 +595,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: @@ -613,7 +613,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"]: @@ -622,7 +622,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: @@ -684,7 +684,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) @@ -695,7 +695,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) @@ -721,7 +721,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), @@ -749,7 +749,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) @@ -767,7 +767,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: @@ -775,7 +775,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) @@ -814,7 +814,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 @@ -836,7 +836,7 @@ usage is void (*_gtk_reserved1)(void);""" # Handle virtual invokers parent = chain[-1] if chain else None if (block and parent): - virtual_annotation = block.get_tag(TAG_VFUNC) + virtual_annotation = block.tags.get(TAG_VFUNC) if virtual_annotation: invoker_name = virtual_annotation.value matched = False -- cgit v1.2.1