Skip to content

Commit

Permalink
[parse_xml] replaced OptionParser with ArgumentParser according
Browse files Browse the repository at this point in the history
to depreciation of first one starting from Python version 3.2.
  • Loading branch information
TheVice authored and nigels-com committed Mar 17, 2019
1 parent f5feecd commit 1b17b0b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions auto/bin/parse_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,34 @@ def writeExtension(f, name, extension, enums, commands):

if __name__ == '__main__':

from optparse import OptionParser
from argparse import ArgumentParser
import os

parser = OptionParser('usage: %prog [options] [XML specs...]')
parser.add_option("--core", dest="core", help="location for core outputs", default='')
parser.add_option("--api", dest="name", help="API name: egl, wgl, glx, etc", default='')
parser.add_option("--extensions", dest="extensions", help="location for extensions outputs", default='')
parser = ArgumentParser(description='usage: %prog [options] [XML specs...]')
parser.add_argument("--core", dest="core", help="location for core outputs", default='')
parser.add_argument("--api", dest="name", help="API name: egl, wgl, glx, etc", default='')
parser.add_argument("--extensions", dest="extensions", help="location for extensions outputs", default='')

(options, args) = parser.parse_args()
(options, args) = parser.parse_known_args()
options = vars(options)

for i in args:

dom = parse(i)
api = findApi(dom, options.name)
api = findApi(dom, options['name'])

print('Found {} enums, {} commands, {} features and {} extensions.'.format(
len(api[0]), len(api[1]), len(api[2]), len(api[3])))

if len(options.core):
if len(options['core']):
for i in api[2].keys():
f = open('%s/%s'%(options.core, i), 'wb')
f = open('%s/%s'%(options['core'], i), 'wb')
writeExtension(f, i, api[2][i], api[0], api[1])
f.close()

if len(options.extensions):
if len(options['extensions']):
for i in api[3].keys():
f = open('%s/%s'%(options.extensions, i), 'wb')
f = open('%s/%s'%(options['extensions'], i), 'wb')
writeExtension(f, i, api[3][i], api[0], api[1])
f.close()

0 comments on commit 1b17b0b

Please sign in to comment.