diff --git a/yaltik_dsl/xml_base.coco b/yaltik_dsl/xml_base.coco index 0bf6b00..89691b6 100644 --- a/yaltik_dsl/xml_base.coco +++ b/yaltik_dsl/xml_base.coco @@ -40,6 +40,7 @@ def xmlroot(tree: Dict[str, Any]) -> ET.Element: (rootel, tree['children']) |*> xmlchild return rootel +# TODO: addpattern here def xmlchild(parent: ET.Element, children: XMLDictElement) -> None: """ Handling of children (ie non root) XML Nodes with/o text and subchildren (recursive) """ @@ -62,13 +63,12 @@ def xmln(tag: XMLText = '', attrs: XMLAttrs = {}, children: Union[str, List] = []) -> XMLDictElement: """ XMLNode with default children, not attributes """ + xmldictel = XMLDictElement$ <*| (tag, attrs) case children: match c is str: - return XMLDictElement(tag=tag, attrs=attrs, children=[c]) - # return {'tag': tag, 'attrs': attrs, 'children': [c]} + return [c] |> xmldictel match c is list: - return XMLDictElement(tag=tag, attrs=attrs, children=c) - # return {'tag': tag, 'attrs': attrs, 'children': c} + return c |> xmldictel else: raise TypeError('Invalid arguments for xmln') diff --git a/yaltik_dsl/xml_base.py b/yaltik_dsl/xml_base.py index 641aded..7a87531 100644 --- a/yaltik_dsl/xml_base.py +++ b/yaltik_dsl/xml_base.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -# __coconut_hash__ = 0x65805ba7 +# __coconut_hash__ = 0xf1882627 # Compiled with Coconut version 1.4.3 [Ernest Scribbler] @@ -75,6 +75,7 @@ def xmlroot(tree # type: Dict[str, Any] (xmlchild)(*(rootel, tree['children'])) return rootel +# TODO: addpattern here def xmlchild(parent, # type: ET.Element children # type: XMLDictElement ): @@ -111,21 +112,20 @@ def xmln(tag='', # type: XMLText ): # type: (...) -> XMLDictElement """ XMLNode with default children, not attributes """ + xmldictel = (_coconut.functools.partial(_coconut.functools.partial, XMLDictElement))(*(tag, attrs)) _coconut_match_to = children _coconut_case_check_1 = False if _coconut.isinstance(_coconut_match_to, str): c = _coconut_match_to _coconut_case_check_1 = True if _coconut_case_check_1: - return XMLDictElement(tag=tag, attrs=attrs, children=[c]) -# return {'tag': tag, 'attrs': attrs, 'children': [c]} + return (xmldictel)([c]) if not _coconut_case_check_1: if _coconut.isinstance(_coconut_match_to, list): c = _coconut_match_to _coconut_case_check_1 = True if _coconut_case_check_1: - return XMLDictElement(tag=tag, attrs=attrs, children=c) -# return {'tag': tag, 'attrs': attrs, 'children': c} + return (xmldictel)(c) if not _coconut_case_check_1: raise TypeError('Invalid arguments for xmln')