[FIX]Yaltik DSL fix xmln with only children
This commit is contained in:
parent
4938cec43d
commit
0c037815b9
@ -628,11 +628,6 @@ def addpattern(base_func, **kwargs):
|
|||||||
raise _coconut.TypeError("addpattern() got unexpected keyword arguments " + _coconut.repr(kwargs))
|
raise _coconut.TypeError("addpattern() got unexpected keyword arguments " + _coconut.repr(kwargs))
|
||||||
return _coconut.functools.partial(_coconut_base_pattern_func, base_func)
|
return _coconut.functools.partial(_coconut_base_pattern_func, base_func)
|
||||||
_coconut_addpattern = addpattern
|
_coconut_addpattern = addpattern
|
||||||
def prepattern(base_func, **kwargs):
|
|
||||||
"""DEPRECATED: Use addpattern instead."""
|
|
||||||
def pattern_prepender(func):
|
|
||||||
return addpattern(func, **kwargs)(base_func)
|
|
||||||
return pattern_prepender
|
|
||||||
class _coconut_partial(object):
|
class _coconut_partial(object):
|
||||||
__slots__ = ("func", "_argdict", "_arglen", "_stargs", "keywords")
|
__slots__ = ("func", "_argdict", "_arglen", "_stargs", "keywords")
|
||||||
if hasattr(_coconut.functools.partial, "__doc__"):
|
if hasattr(_coconut.functools.partial, "__doc__"):
|
||||||
@ -714,9 +709,6 @@ def makedata(data_type, *args):
|
|||||||
if _coconut.issubclass(data_type, _coconut.str):
|
if _coconut.issubclass(data_type, _coconut.str):
|
||||||
return "".join(args)
|
return "".join(args)
|
||||||
return data_type(args)
|
return data_type(args)
|
||||||
def datamaker(data_type):
|
|
||||||
"""DEPRECATED: Use makedata instead."""
|
|
||||||
return _coconut.functools.partial(makedata, data_type)
|
|
||||||
def fmap(func, obj):
|
def fmap(func, obj):
|
||||||
"""fmap(func, obj) creates a copy of obj with func applied to its contents.
|
"""fmap(func, obj) creates a copy of obj with func applied to its contents.
|
||||||
Override by defining obj.__fmap__(func)."""
|
Override by defining obj.__fmap__(func)."""
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0x4a7a90c3
|
# __coconut_hash__ = 0x73d2bb80
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
'name': 'Yaltik Odoo DSL base module and fns',
|
'name': 'Yaltik Odoo DSL base module and fns',
|
||||||
'summary': 'Yaltik Odoo Domain Specific Language base module and functions',
|
'summary': 'Yaltik Odoo Domain Specific Language base module and functions',
|
||||||
'description': """ Yaltik Odoo Domain Specific Language base module and functions """,
|
'description': """ Yaltik Odoo Domain Specific Language base module and functions """,
|
||||||
'version': '10.0.0.3.0',
|
'version': '10.0.0.3.1',
|
||||||
'category': 'Yaltik',
|
'category': 'Yaltik',
|
||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0x992b21a8
|
# __coconut_hash__ = 0xb0af9f53
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0xdf0c086d
|
# __coconut_hash__ = 0xb59e6156
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
|
@ -45,6 +45,15 @@ class TestXMLBase(unittest.TestCase):
|
|||||||
with self.assertRaisesRegexp(TypeError, 'Invalid arguments'):
|
with self.assertRaisesRegexp(TypeError, 'Invalid arguments'):
|
||||||
xmln <**| {'children': False}
|
xmln <**| {'children': False}
|
||||||
|
|
||||||
|
# Ensure that only children after tags is managed
|
||||||
|
element = xmln <*| ('tag', {'something': 'inside'})
|
||||||
|
element.attrs `self.assertIsInstance` dict
|
||||||
|
element.children `self.assertIsInstance` list
|
||||||
|
|
||||||
|
element = xmln <*| ('tag', ['something', 'inside'])
|
||||||
|
element.attrs `self.assertIsInstance` dict
|
||||||
|
element.children `self.assertIsInstance` list
|
||||||
|
|
||||||
|
|
||||||
def test_xmlchild(self):
|
def test_xmlchild(self):
|
||||||
parent = {'tag': 'root', 'attrs': {}, 'children': []} |> xmlroot
|
parent = {'tag': 'root', 'attrs': {}, 'children': []} |> xmlroot
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0xd35c4ffa
|
# __coconut_hash__ = 0x84c101a5
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
@ -71,6 +71,15 @@ class TestXMLBase(unittest.TestCase):
|
|||||||
with self.assertRaisesRegexp(TypeError, 'Invalid arguments'):
|
with self.assertRaisesRegexp(TypeError, 'Invalid arguments'):
|
||||||
(xmln)(**{'children': False})
|
(xmln)(**{'children': False})
|
||||||
|
|
||||||
|
# Ensure that only children after tags is managed
|
||||||
|
element = (xmln)(*('tag', {'something': 'inside'}))
|
||||||
|
(self.assertIsInstance)(element.attrs, dict)
|
||||||
|
(self.assertIsInstance)(element.children, list)
|
||||||
|
|
||||||
|
element = (xmln)(*('tag', ['something', 'inside']))
|
||||||
|
(self.assertIsInstance)(element.attrs, dict)
|
||||||
|
(self.assertIsInstance)(element.children, list)
|
||||||
|
|
||||||
|
|
||||||
def test_xmlchild(self):
|
def test_xmlchild(self):
|
||||||
parent = (xmlroot)({'tag': 'root', 'attrs': {}, 'children': []})
|
parent = (xmlroot)({'tag': 'root', 'attrs': {}, 'children': []})
|
||||||
|
@ -59,6 +59,10 @@ def xmln(tag: Text = '',
|
|||||||
attrs: XMLAttrs = {},
|
attrs: XMLAttrs = {},
|
||||||
children: Union[Text, List] = []) -> XMLDictElement:
|
children: Union[Text, List] = []) -> XMLDictElement:
|
||||||
""" XMLDictElement building from dict object, with defaults """
|
""" XMLDictElement building from dict object, with defaults """
|
||||||
|
case attrs:
|
||||||
|
match _ is list:
|
||||||
|
children = attrs
|
||||||
|
attrs = {}
|
||||||
xmldictel = XMLDictElement$ <*| (tag, attrs)
|
xmldictel = XMLDictElement$ <*| (tag, attrs)
|
||||||
case children:
|
case children:
|
||||||
match c is Text:
|
match c is Text:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0x970fdbe8
|
# __coconut_hash__ = 0x178765c5
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
@ -109,21 +109,28 @@ def xmln(tag='', # type: Text
|
|||||||
):
|
):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
""" XMLDictElement building from dict object, with defaults """
|
""" XMLDictElement building from dict object, with defaults """
|
||||||
|
_coconut_match_to = attrs
|
||||||
|
_coconut_case_check_1 = False
|
||||||
|
if _coconut.isinstance(_coconut_match_to, list):
|
||||||
|
_coconut_case_check_1 = True
|
||||||
|
if _coconut_case_check_1:
|
||||||
|
children = attrs
|
||||||
|
attrs = {}
|
||||||
xmldictel = (_coconut.functools.partial(_coconut.functools.partial, XMLDictElement))(*(tag, attrs))
|
xmldictel = (_coconut.functools.partial(_coconut.functools.partial, XMLDictElement))(*(tag, attrs))
|
||||||
_coconut_match_to = children
|
_coconut_match_to = children
|
||||||
_coconut_case_check_1 = False
|
_coconut_case_check_2 = False
|
||||||
if _coconut.isinstance(_coconut_match_to, Text):
|
if _coconut.isinstance(_coconut_match_to, Text):
|
||||||
c = _coconut_match_to
|
c = _coconut_match_to
|
||||||
_coconut_case_check_1 = True
|
_coconut_case_check_2 = True
|
||||||
if _coconut_case_check_1:
|
if _coconut_case_check_2:
|
||||||
return (xmldictel)([c])
|
return (xmldictel)([c])
|
||||||
if not _coconut_case_check_1:
|
if not _coconut_case_check_2:
|
||||||
if _coconut.isinstance(_coconut_match_to, list):
|
if _coconut.isinstance(_coconut_match_to, list):
|
||||||
c = _coconut_match_to
|
c = _coconut_match_to
|
||||||
_coconut_case_check_1 = True
|
_coconut_case_check_2 = True
|
||||||
if _coconut_case_check_1:
|
if _coconut_case_check_2:
|
||||||
return (xmldictel)(c)
|
return (xmldictel)(c)
|
||||||
if not _coconut_case_check_1:
|
if not _coconut_case_check_2:
|
||||||
raise TypeError('Invalid arguments for xmln')
|
raise TypeError('Invalid arguments for xmln')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user