From 07eb8db186decff3949289d0ef341e2f9ca604e8 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Sun, 9 Apr 2017 14:40:19 -0500 Subject: [PATCH] fixes #555 --- nxdlTypes.xsd | 24 +++++++++++------------ utils/types2rst.py | 48 ++-------------------------------------------- 2 files changed, 14 insertions(+), 58 deletions(-) diff --git a/nxdlTypes.xsd b/nxdlTypes.xsd index 36636c1985..4ce9e1e8ea 100644 --- a/nxdlTypes.xsd +++ b/nxdlTypes.xsd @@ -418,18 +418,18 @@ any valid NeXus type - - any string representation - any representation of a floating point number - any representation of an integer number - any representation of an unsigned integer number (includes zero) - any representation of a positive integer number (greater than zero) - any valid NeXus number representation - alias of ISO8601 - ISO 8601 date and time representation (http://www.w3.org/TR/NOTE-datetime) - true/false value ( true | 1 | false | 0 ) - any representation of binary data - if text, line terminator is [CR][LF] - + diff --git a/utils/types2rst.py b/utils/types2rst.py index 203852b80c..1fc081c628 100755 --- a/utils/types2rst.py +++ b/utils/types2rst.py @@ -8,55 +8,11 @@ ''' -import os, sys -import lxml.etree - - -def worker(nodeMatchString, section = 'units'): - if len(sys.argv) != 2: - print("usage: %s nxdlTypes.xsd" % sys.argv[0]) - exit() - NXDL_TYPES_FILE = sys.argv[1] - if not os.path.exists(NXDL_TYPES_FILE): - print("Cannot find %s" % NXDL_TYPES_FILE) - exit() - - tree = lxml.etree.parse(NXDL_TYPES_FILE) - - output = ['.. auto-generated by %s -- DO NOT EDIT' % sys.argv[0]] - output.append('') - - labels = ('term', 'description') - output.append('.. nodeMatchString : %s' % nodeMatchString) - output.append('') - db = {} - - NAMESPACE = 'http://www.w3.org/2001/XMLSchema' - ns = {'xs': NAMESPACE} - root = tree.xpath('//xs:schema', namespaces=ns)[0] - s = '//xs:simpleType' - for node in tree.xpath("//xs:simpleType", namespaces=ns): - if node.get('name') == nodeMatchString: - for item in node.xpath('xs:restriction//xs:enumeration', namespaces=ns): - key = '%s' % item.get('value') - words = item.xpath('xs:annotation/xs:documentation', namespaces=ns)[0] - db[key] = words.text - - print('\n'.join(output)) - - # this list is too long to make this a table in latex - # for two columns, a Sphinx fieldlist will do just as well - for key in sorted(db): - print('.. index:: ! %s (%s type)\n' % (key, section)) # index entry - print('.. _%s:\n' % key) # cross-reference point - print(':%s:' % key) - for line in db[key].splitlines(): - print(' %s' % line) - print('') +import units2rst if __name__ == '__main__': - worker('NAPI', section = 'data') + units2rst.worker('NAPI', section = 'data') # NeXus - Neutron and X-ray Common Data Format