diff options
author | Jordan Justen <[email protected]> | 2017-08-17 15:44:53 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2019-02-21 13:15:59 -0800 |
commit | a9b0b72a786d270e1fa09e5d4741c498c4c66247 (patch) | |
tree | 59b2b07577f5c42a934eefaa0f97b4d547869e8e | |
parent | cd0ced49e7957182d23e21657445b720184ea425 (diff) |
genxml/gen_bits_header.py: Use regex to strip no alphanum chars
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Sagar Ghuge <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r-- | src/intel/genxml/gen_bits_header.py | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/intel/genxml/gen_bits_header.py b/src/intel/genxml/gen_bits_header.py index ded2d2dcfcf..aac49fb49e2 100644 --- a/src/intel/genxml/gen_bits_header.py +++ b/src/intel/genxml/gen_bits_header.py @@ -25,6 +25,7 @@ from __future__ import ( import argparse import os +import re import xml.parsers.expat from mako.template import Template @@ -130,33 +131,10 @@ ${emit_per_gen_prop_func(field, 'start')} #endif /* ${guard} */""", output_encoding='utf-8') +alphanum_nono = re.compile(r'[ /\[\]()\-:.,=>#&*"+\\]+') def to_alphanum(name): - substitutions = { - ' ': '', - '/': '', - '[': '', - ']': '', - '(': '', - ')': '', - '-': '', - ':': '', - '.': '', - ',': '', - '=': '', - '>': '', - '#': '', - 'α': 'alpha', - '&': '', - '*': '', - '"': '', - '+': '', - '\'': '', - } - - for i, j in substitutions.items(): - name = name.replace(i, j) - - return name + global alphanum_nono + return alphanum_nono.sub('', name).replace('α', 'alpha') def safe_name(name): name = to_alphanum(name) |