diff options
Diffstat (limited to 'gr-utils/blocktool/core/parseheader_generic.py')
-rw-r--r-- | gr-utils/blocktool/core/parseheader_generic.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/gr-utils/blocktool/core/parseheader_generic.py b/gr-utils/blocktool/core/parseheader_generic.py index c28c6824c7..0e00ba56f8 100644 --- a/gr-utils/blocktool/core/parseheader_generic.py +++ b/gr-utils/blocktool/core/parseheader_generic.py @@ -9,6 +9,7 @@ """ Module to generate AST for the headers and parse it """ +import time import os import re import codecs @@ -22,7 +23,6 @@ from ..core import Constants LOGGER = logging.getLogger(__name__) PYGCCXML_AVAILABLE = False # ugly hack to make pygccxml work with Python >= 3.8 -import time try: time.clock except: @@ -35,6 +35,7 @@ except: from ...modtool.tools import ParserCCBlock from ...modtool.cli import ModToolException + class GenericHeaderParser(BlockTool): """ : Single argument required: file_path @@ -47,7 +48,7 @@ class GenericHeaderParser(BlockTool): name = 'Block Parse Header' description = 'Create a parsed output from a block header file' - def __init__(self, file_path=None, blocktool_comments=False, define_symbols=None, include_paths=None, **kwargs): + def __init__(self, file_path=None, blocktool_comments=False, define_symbols=None, include_paths=None, **kwargs): """ __init__ """ BlockTool.__init__(self, **kwargs) self.parsed_data = {} @@ -63,8 +64,6 @@ class GenericHeaderParser(BlockTool): file_path = os.path.abspath(file_path) self.target_file = file_path - - self.initialize() self.validate() @@ -84,7 +83,7 @@ class GenericHeaderParser(BlockTool): if not os.path.basename(self.module).startswith(Constants.GR): self.module = os.path.abspath( os.path.join(self.module, os.pardir)) - + self.modname = os.path.basename(self.module) self.filename = os.path.basename(self.target_file) self.targetdir = os.path.dirname(self.target_file) @@ -104,9 +103,10 @@ class GenericHeaderParser(BlockTool): fname_h))[0] fname_cc = blockname + '_impl' + '.cc' contains_modulename = blockname.startswith( - self.modname+'_') - blockname = blockname.replace(self.modname+'_', '', 1) - fname_cc = os.path.join(fname_h.split('include')[0],'lib',fname_cc) + self.modname + '_') + blockname = blockname.replace(self.modname + '_', '', 1) + fname_cc = os.path.join(fname_h.split( + 'include')[0], 'lib', fname_cc) return (blockname, fname_cc, contains_modulename) # Go, go, go LOGGER.info("Making GRC bindings for {}...".format(fname_h)) @@ -123,7 +123,7 @@ class GenericHeaderParser(BlockTool): "Can't open some of the files necessary to parse {}.".format(fname_cc)) if contains_modulename: - return (parser.read_params(), parser.read_io_signature(), self.modname+'_'+blockname) + return (parser.read_params(), parser.read_io_signature(), self.modname + '_' + blockname) else: return (parser.read_params(), parser.read_io_signature(), blockname) @@ -171,7 +171,7 @@ class GenericHeaderParser(BlockTool): allow_empty=True, recursive=False, header_file=self.target_file) for fcn in functions: - if str(fcn.name) not in [class_decl.name, '~'+class_decl.name]: + if str(fcn.name) not in [class_decl.name, '~' + class_decl.name]: member_functions.append(self.parse_function(fcn)) class_dict['member_functions'] = member_functions @@ -295,17 +295,17 @@ class GenericHeaderParser(BlockTool): mf_dict = { "name": "make", - "return_type": "::".join(namespace_to_parse + [blockname,"sptr"]), + "return_type": "::".join(namespace_to_parse + [blockname, "sptr"]), "has_static": "1" } - + args = [] - + for p in params: arg_dict = { - "name":p['key'], - "dtype":p['type'], - "default":p['default'] + "name": p['key'], + "dtype": p['type'], + "default": p['default'] } args.append(arg_dict) @@ -341,7 +341,8 @@ class GenericHeaderParser(BlockTool): raise BlockToolException('namespace cannot be none') self.parsed_data['target_namespace'] = namespace_to_parse - self.parsed_data['namespace'] = self.parse_namespace(main_namespace) + self.parsed_data['namespace'] = self.parse_namespace( + main_namespace) # except RuntimeError: # raise BlockToolException( |