Skip to content

Commit 2f31728

Browse files
committed
Adding documentation for the schema, virtual python setup script
1 parent 58daac0 commit 2f31728

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

pygeos_package/pygeos/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
__version__ = '0.3.0'
2+
__version__ = '0.3.1'
33

44

55
from .regex_config import regexConfig, symbolicMathRegexHandler, parameterHandler, DictRegexHandler
66
from .unit_manager import unitManager
7-
from .xml_processor import preprocessGEOSXML
7+
from .xml_processor import preprocessGEOSXML, validateXML
88
from .table_generator import writeGEOSTable, readGEOSTable
99
from .test_manager import runUnitTests
1010
from .format_xml import format_xml_file

pygeos_package/pygeos/xml_processor.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,24 @@ def preprocessGEOSXML(inputFile, schema='/g/g17/sherman/GEOS/geosx/src/component
159159

160160
if (verbose > 0):
161161
print('Preprocessed xml file stored in %s' % (recordName))
162-
163-
# Validate against the schema
164-
print('Validating the xml against the schema...')
165-
try:
166-
ofile = ElementTree.parse(recordName)
167-
sfile = ElementTree.XMLSchema(ElementTree.parse(os.path.expanduser(schema)))
168-
sfile.assertValid(ofile)
169-
print('Done!')
170-
except ElementTree.DocumentInvalid as err:
171-
print('\nWarning: input XML contains potentially invalid input parameters:')
172-
print('-'*20+'\n')
173-
print(sfile.error_log)
174-
print('\n'+'-'*20)
175-
print('(Total schema warnings: %i)\n' % (len(sfile.error_log)))
162+
validateXML(recordName, schema)
176163

177164
return recordName
165+
166+
167+
def validateXML(fname, schema):
168+
print('Validating the xml against the schema...')
169+
try:
170+
ofile = ElementTree.parse(fname)
171+
sfile = ElementTree.XMLSchema(ElementTree.parse(os.path.expanduser(schema)))
172+
sfile.assertValid(ofile)
173+
print('Done!')
174+
except ElementTree.DocumentInvalid as err:
175+
print(err)
176+
print('\nWarning: input XML contains potentially invalid input parameters:')
177+
print('-'*20+'\n')
178+
print(sfile.error_log)
179+
print('\n'+'-'*20)
180+
print('(Total schema warnings: %i)\n' % (len(sfile.error_log)))
181+
182+

0 commit comments

Comments
 (0)