[REF]Yaltik DSL : XML Base better xmln
This commit is contained in:
parent
cfb99c113d
commit
742d395427
@ -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')
|
||||
|
||||
|
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user