diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-29 16:08:27 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-31 16:03:58 -0700 |
commit | f931b851cd532900551e8b3dad65b727f9c1e25e (patch) | |
tree | e92f19a74e068b451d074cc1a2bc7fa58928c0ec | |
parent | 766c6e1e76e25aea933086e73587cd103a85f9d0 (diff) |
glapi: gl_XML.py: simplify is_attr_true
Use a boolean instead of 0 or 1, and use an assert rather than a runtime
error.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | src/mapi/glapi/gen/gl_XML.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 334fd6e683..34f987ee3b 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -66,15 +66,13 @@ def is_attr_true(element, name, default="false"): The value read from the attribute list must be either 'true' or 'false'. If the value is 'false', zero will be returned. If the value is 'true', non-zero will be returned. An exception will be - raised for any other value.""" + raised for any other value. + """ value = element.get(name, default) - if value == "true": - return 1 - elif value == "false": - return 0 - else: - raise RuntimeError('Invalid value "%s" for boolean "%s".' % (value, name)) + assert value in ('true', 'false'), 'value {} was not a bool'.format(value) + + return value == 'true' class gl_print_base(object): |