def create_child(nodeClass, **kwargs): """ Creates a child node of the given parent node, from the given libclang cursor If a mapping of the cursor kind is found (See Node class docstring above) an instance of the corresponding Node subclass is returned. Else None is returned. """ if hasattr(nodeClass, 'MEMBERS_MAPPING'): cursor = kwargs['cursor'] mapping = nodeClass.MEMBERS_MAPPING() if cursor.kind in mapping: class_ = mapping[cursor.kind] return class_.create_node(**kwargs) else: GlobalLogger.warning().step('{} has no {} mapping'.format(nodeClass.__name__, cursor.kind)) return None
def create_child(nodeClass, **kwargs): """ Creates a child node of the given parent node, from the given libclang cursor If a mapping of the cursor kind is found (See Node class docstring above) an instance of the corresponding Node subclass is returned. Else None is returned. """ if hasattr(nodeClass, 'MEMBERS_MAPPING'): cursor = kwargs['cursor'] mapping = nodeClass.MEMBERS_MAPPING() if cursor.kind in mapping: class_ = mapping[cursor.kind] return class_.create_node(**kwargs) else: GlobalLogger.warning().step('{} has no {} mapping'.format( nodeClass.__name__, cursor.kind)) return None