Commit 89a89d86 authored by Dave Kuhlman's avatar Dave Kuhlman
Browse files

Added rem dups unit tests for Version 2.24a

parent 3276fa21
No related merge requests found
Showing with 1192 additions and 0 deletions
+1192 -0
<?xml version="1.0" ?>
<authors>
<author>
<description>description one</description>
</author>
<author>
<description>description two</description>
</author>
<cooperation>sample cooperation one</cooperation>
<author>
<description>description three</description>
</author>
<cooperation>sample cooperation two</cooperation>
<author>
<description>description four</description>
</author>
<cooperation>sample cooperation three</cooperation>
</authors>
<xsd:schema
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>
<xsd:element name="authors" type="authorsType" />
<xsd:complexType name="authorsType">
<xsd:sequence>
<xsd:element ref="author"/>
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element ref="author"/>
<xsd:element name="cooperation" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="author">
<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<?xml version="1.0" ?>
<authors>
<author>
<description>description one</description>
</author>
<author>
<description>description two</description>
</author>
<author>
<description>description three</description>
</author>
<author>
<description>description four</description>
</author>
<cooperation>sample cooperation one</cooperation>
<cooperation>sample cooperation two</cooperation>
<cooperation>sample cooperation three</cooperation>
</authors>
#!/usr/bin/env python
#
# Generated by generateDS.py.
#
# Command line options:
# ('--no-dates', '')
# ('--no-versions', '')
# ('--member-specs', 'list')
# ('-f', '')
# ('-a', 'xsd:')
# ('-o', 'tests/rem_dup_elems2_sup.py')
# ('-s', 'tests/rem_dup_elems2_sub.py')
# ('--super', 'rem_dup_elems2_sup')
# ('--no-warnings', '')
#
# Command line arguments:
# tests/rem_dup_elems.xsd
#
# Command line:
# generateDS.py --no-dates --no-versions --member-specs="list" -f -a "xsd:" -o "tests/rem_dup_elems2_sup.py" -s "tests/rem_dup_elems2_sub.py" --super="rem_dup_elems2_sup" --no-warnings tests/rem_dup_elems.xsd
#
# Current working directory (os.getcwd()):
# generateds
#
import sys
from lxml import etree as etree_
import rem_dup_elems2_sup as supermod
def parsexml_(infile, parser=None, **kwargs):
if parser is None:
# Use the lxml ElementTree compatible parser so that, e.g.,
# we ignore comments.
parser = etree_.ETCompatXMLParser()
doc = etree_.parse(infile, parser=parser, **kwargs)
return doc
#
# Globals
#
ExternalEncoding = 'ascii'
#
# Data representation classes
#
class authorsTypeSub(supermod.authorsType):
def __init__(self, author=None, cooperation=None):
super(authorsTypeSub, self).__init__(author, cooperation, )
supermod.authorsType.subclass = authorsTypeSub
# end class authorsTypeSub
class authorSub(supermod.author):
def __init__(self, description=None):
super(authorSub, self).__init__(description, )
supermod.author.subclass = authorSub
# end class authorSub
def get_root_tag(node):
tag = supermod.Tag_pattern_.match(node.tag).groups()[-1]
rootClass = None
rootClass = supermod.GDSClassesMapping.get(tag)
if rootClass is None and hasattr(supermod, tag):
rootClass = getattr(supermod, tag)
return tag, rootClass
def parse(inFilename, silence=False):
parser = None
doc = parsexml_(inFilename, parser)
rootNode = doc.getroot()
rootTag, rootClass = get_root_tag(rootNode)
if rootClass is None:
rootTag = 'authorsType'
rootClass = supermod.authorsType
rootObj = rootClass.factory()
rootObj.build(rootNode)
# Enable Python to collect the space used by the DOM.
doc = None
if not silence:
sys.stdout.write('<?xml version="1.0" ?>\n')
rootObj.export(
sys.stdout, 0, name_=rootTag,
namespacedef_='',
pretty_print=True)
return rootObj
def parseEtree(inFilename, silence=False):
parser = None
doc = parsexml_(inFilename, parser)
rootNode = doc.getroot()
rootTag, rootClass = get_root_tag(rootNode)
if rootClass is None:
rootTag = 'authorsType'
rootClass = supermod.authorsType
rootObj = rootClass.factory()
rootObj.build(rootNode)
# Enable Python to collect the space used by the DOM.
doc = None
mapping = {}
rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
if not silence:
content = etree_.tostring(
rootElement, pretty_print=True,
xml_declaration=True, encoding="utf-8")
sys.stdout.write(content)
sys.stdout.write('\n')
return rootObj, rootElement, mapping, reverse_mapping
def parseString(inString, silence=False):
from StringIO import StringIO
parser = None
doc = parsexml_(StringIO(inString), parser)
rootNode = doc.getroot()
rootTag, rootClass = get_root_tag(rootNode)
if rootClass is None:
rootTag = 'authorsType'
rootClass = supermod.authorsType
rootObj = rootClass.factory()
rootObj.build(rootNode)
# Enable Python to collect the space used by the DOM.
doc = None
if not silence:
sys.stdout.write('<?xml version="1.0" ?>\n')
rootObj.export(
sys.stdout, 0, name_=rootTag,
namespacedef_='')
return rootObj
def parseLiteral(inFilename, silence=False):
parser = None
doc = parsexml_(inFilename, parser)
rootNode = doc.getroot()
rootTag, rootClass = get_root_tag(rootNode)
if rootClass is None:
rootTag = 'authorsType'
rootClass = supermod.authorsType
rootObj = rootClass.factory()
rootObj.build(rootNode)
# Enable Python to collect the space used by the DOM.
doc = None
if not silence:
sys.stdout.write('#from rem_dup_elems2_sup import *\n\n')
sys.stdout.write('import rem_dup_elems2_sup as model_\n\n')
sys.stdout.write('rootObj = model_.rootClass(\n')
rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
sys.stdout.write(')\n')
return rootObj
USAGE_TEXT = """
Usage: python ???.py <infilename>
"""
def usage():
print(USAGE_TEXT)
sys.exit(1)
def main():
args = sys.argv[1:]
if len(args) != 1:
usage()
infilename = args[0]
parse(infilename)
if __name__ == '__main__':
#import pdb; pdb.set_trace()
main()
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment