# under the License.
import os.path
+import re
from lxml import etree
XMLNS_VOLUME_V2 = ('http://docs.openstack.org/api/openstack-volume/2.0/'
'content')
+_split_pattern = re.compile(r'([^:{]*{[^}]*}[^:]*|[^:]+)')
+
def validate_schema(xml, schema_name):
if isinstance(xml, str):
pass
return tmpattrib
+ @staticmethod
+ def _splitTagName(name):
+ return _split_pattern.findall(name)
+
def _render(self, parent, datum, patches, nsmap):
"""Internal rendering.
else:
tmpattrib = {}
- tagnameList = tagname.split(':')
+ tagnameList = self._splitTagName(tagname)
insertIndex = 0
#If parent is not none and has same tagname
self.assertEqual(len(siblings), 1)
self.assertEqual(siblings[0], elem)
+ def test__splitTagName(self):
+ test_cases = [
+ ('a', ['a']),
+ ('a:b', ['a', 'b']),
+ ('{http://test.com}a:b', ['{http://test.com}a', 'b']),
+ ('a:b{http://test.com}:c', ['a', 'b{http://test.com}', 'c']),
+ ]
+
+ for test_case, expected in test_cases:
+ result = xmlutil.TemplateElement._splitTagName(test_case)
+ self.assertEqual(expected, result)
+
def test__nsmap(self):
# Set up a basic template
elem = xmlutil.TemplateElement('test')