X-Git-Url: http://git.ithinksw.org/~jspiros/python-ebml.git/blobdiff_plain/f1ea34ada2ec6e900703bae7863837ad2b8287f1..2c0fa7458ba3bb7b65ab6675233096c575bee9e5:/ebml/schema/specs.py?ds=inline diff --git a/ebml/schema/specs.py b/ebml/schema/specs.py index 8c27e9f..d6e7728 100644 --- a/ebml/schema/specs.py +++ b/ebml/schema/specs.py @@ -34,7 +34,7 @@ def parse_specdata(source, doc_name, doc_type, doc_version): elements = {} globals = [] - def child_elements(parent_level, element_list): + def child_elements(parent_level, element_list, upper_recursive=None): children = [] while element_list: raw_element = element_list[0] @@ -69,10 +69,19 @@ def parse_specdata(source, doc_name, doc_type, doc_version): except (KeyError, ValueError): element_attrs['default'] = None - element_attrs['children'], element_list = child_elements(element_level if not is_global else 0, element_list) - element = type(element_name, (Element,), element_attrs) elements[element_name] = element + + recursive = [] + if upper_recursive: + recursive.extend(upper_recursive) + if raw_attrs.get('recursive', False) == '1': + recursive.append(element) + + element_children, element_list = child_elements(element_level if not is_global else 0, element_list, recursive) + element_children += tuple(recursive) + element.children = element_children + if is_global: globals.append(element) else: