diff --git a/coolamqp/framing/compilation/xml_fields.py b/coolamqp/framing/compilation/xml_fields.py index 18d7cb376428932fdf427fb6e6aab9f79f33e9a3..44d2dbf1ff06401668d639969a26c3e50bbed7b5 100644 --- a/coolamqp/framing/compilation/xml_fields.py +++ b/coolamqp/framing/compilation/xml_fields.py @@ -12,7 +12,7 @@ def nop(x): __all__ = [ '_name', '_docs', '_ComputedField', '_ValueField', '_SimpleField', - 'get_docs' + '_docs_with_label' ] class _Field(object): @@ -65,7 +65,7 @@ class _SimpleField(_ValueField): super(_SimpleField, self).__init__(name, name, field_type, default) -def get_docs(elem, label=False): +def get_docs(elem, label): """Parse an XML element. Return documentation""" for kid in elem.getchildren(): @@ -79,6 +79,7 @@ def get_docs(elem, label=False): return elem.attrib.get('label', None) _name = _SimpleField('name', six.text_type) -_docs = _ComputedField('docs', lambda elem: get_docs(elem)) +_docs = _ComputedField('docs', lambda elem: get_docs(elem, False)) +_docs_with_label = _ComputedField('docs', lambda elem: get_docs(elem, True)) diff --git a/coolamqp/framing/compilation/xml_tags.py b/coolamqp/framing/compilation/xml_tags.py index 7c7faa80daa8cbd5a92929534ebba3fc78cebe34..082cf7a9e9826a69ef6c4fe49a7640c01a8d28b2 100644 --- a/coolamqp/framing/compilation/xml_tags.py +++ b/coolamqp/framing/compilation/xml_tags.py @@ -3,7 +3,7 @@ from __future__ import print_function, absolute_import, division import six import logging import copy - +import math from coolamqp.framing.base import BASIC_TYPES, DYNAMIC_BASIC_TYPES from .xml_fields import * @@ -17,6 +17,7 @@ __all__ = [ 'Domain', 'Method', 'Class', 'Field', 'Constant' ] + class BaseObject(object): FIELDS = [] @@ -60,12 +61,10 @@ class Class(BaseObject): FIELDS = [ _name, _SimpleField('index', int), - _ComputedField('docs', lambda elem: get_docs(elem, label=True)), - _ComputedField('methods', lambda elem: sorted( - [Method(me) for me in elem.getchildren() if me.tag == 'method'], + _docs_with_label, + _ComputedField('methods', lambda elem: sorted(map(Method, _get_tagchild(elem, 'method')), key=lambda m: (m.name.strip('-')[0], -len(m.response)))), - _ComputedField('properties', lambda elem: [Field(e) for e in elem.getchildren() if - e.tag == 'field']) + _ComputedField('properties', lambda elem: map(Field, _get_tagchild(elem, 'field'))) ]