def _process_packagenode(self): logging.info("Processing package node") data_nodes = [] for member in SpdxAnalyzer.__membersof(self.doc.package): value = self.doc.package.__getattribute__(member) if member == "license_declared": data_nodes.append( InfoNode.DataNode(type=member, data=value.full_name)) continue data_nodes.append( InfoNode.DataNode(type=member, data=SpdxAnalyzer.__stringify(value))) info_node = InfoNode(type="metadata", dataNodes=data_nodes) package_request = PackageRequest() package_node = self.cserv.GetPackageNode(package_request) info_nodes = [] info_nodes.append( InfoNodeMessage(uid=package_node.uid, token=self.token, infonode=info_node)) info_iterator = _generate_iterator(info_nodes) self.aserv.SendInfoNodes(info_iterator)
def _process_filenodes(self): const_type = "sourcecode" query_node = FileNode(type=const_type) stream_resp = self.cserv.GetFileNode(query_node) for node in stream_resp: logging.info("Analyze node {}".format(node.path)) filtered_files = list( filter(lambda f: node.path.endswith(f.name), self.doc.files)) if not filtered_files: logging.warn("File {} not found in SPDX document".format( node.path)) continue spdx_doc_file_info = filtered_files[0] if not isinstance(spdx_doc_file_info.conc_lics, License): continue data_nodes = [] logging.info("Concluded license {}".format( spdx_doc_file_info.conc_lics)) data_nodes.append( InfoNode.DataNode( type="spdxIdentifier", data=spdx_doc_file_info.conc_lics.identifier)) data_nodes.append( InfoNode.DataNode(type="name", data=spdx_doc_file_info.conc_lics.full_name)) info_node = InfoNode(type="license", dataNodes=data_nodes) info_nodes = [] info_nodes.append( InfoNodeMessage(uid=node.uid, token=self.token, infonode=info_node)) info_iterator = _generate_iterator(info_nodes) self.aserv.SendInfoNodes(info_iterator)