diff options
author | Josh Morman <mormjb@gmail.com> | 2020-06-11 11:32:11 -0400 |
---|---|---|
committer | Josh Morman <mormjb@gmail.com> | 2020-06-11 11:32:11 -0400 |
commit | a7436c3062aa6e81e476b283f571626b8dd73a07 (patch) | |
tree | a015f94d3f792e494be2c7681849d197e242ff96 /gr-utils/bindtool/scripts/header_utils.py | |
parent | 3c302ef4c1655ff27c3f66a924d897a6fdd07060 (diff) |
pybind: add exception handling to pybind header parsing
Diffstat (limited to 'gr-utils/bindtool/scripts/header_utils.py')
-rw-r--r-- | gr-utils/bindtool/scripts/header_utils.py | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/gr-utils/bindtool/scripts/header_utils.py b/gr-utils/bindtool/scripts/header_utils.py index 165124e969..4071f6fa86 100644 --- a/gr-utils/bindtool/scripts/header_utils.py +++ b/gr-utils/bindtool/scripts/header_utils.py @@ -6,43 +6,51 @@ import re class PybindHeaderParser: def __init__(self, pathname): - with open(pathname,'r') as f: - self.file_txt = f.read() + try: + with open(pathname,'r') as f: + self.file_txt = f.read() + except: + self.file_txt = "" def get_flag_automatic(self): - # p = re.compile(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)') - # m = p.search(self.file_txt) - m = re.search(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)', self.file_txt) - if (m and m.group(1) == '1'): - return True - else: + try: + m = re.search(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)', self.file_txt) + if (m and m.group(1) == '1'): + return True + else: + return False + except: return False - - def get_flag_pygccxml(self): - # p = re.compile(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)') - # m = p.search(self.file_txt) - m = re.search(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)', self.file_txt) - if (m and m.group(1) == '1'): - return True - else: + + def get_flag_pygccxml(self): + try: + m = re.search(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)', self.file_txt) + if (m and m.group(1) == '1'): + return True + else: + return False + except: return False def get_header_filename(self): - # p = re.compile(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)') - # m = p.search(self.file_txt) - m = re.search(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)', self.file_txt) - if (m): - return m.group(1) - else: + try: + m = re.search(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)', self.file_txt) + if (m): + return m.group(1) + else: + return None + except: return None + def get_header_file_hash(self): - # p = re.compile(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)') - # m = p.search(self.file_txt) - m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', self.file_txt) - if (m): - return m.group(1) - else: + try: + m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', self.file_txt) + if (m): + return m.group(1) + else: + return None + except: return None def get_flags(self): |