def reqs_limit(self, reqset): # Get a list of all topic names. self.build_named_nodes() topic_name_list = self.named_nodes.keys() # Create the new RequirementSet r = RequirementSet(reqset.mods, reqset.opts, reqset.config) # Copy over the requirements themselves: # Here the incoming and outgoing requirements are the still the # old ones. # During the loop, build up the mapping from old to new. def copy_only_reqs(lreqset, ltopic_name_list, lall_topic_names): old2new = {} for _, req in lreqset.reqs.iteritems(): topic = req.get_value("Topic") # If the referenced topic does not exists at all, emit # an error. if topic not in lall_topic_names: lreqset.error(58, "Topic does not exist. Typo " "in topic name?", req.id) lreqset.not_usable() continue if not req.get_value("Topic") in ltopic_name_list: lreqset.debug(65, "Skipping requirement because " "not in topic", req.id) continue req_copy = req.internal_copy_phase1(ltopic_name_list) r.add_req(req_copy) old2new[req] = req_copy return old2new old2new = copy_only_reqs(reqset, topic_name_list, self.all_topic_names) # Replace all the incoming and outgoing from old to new: for _, req in r.reqs.iteritems(): req.internal_copy_phase2(old2new) # Now there is a fully limited version of the requirement set # to the topic set. Assign the requirements to the given # topics. self.internal_depict(r) # There is the need for some tests (e.g. is the remaining graph # connected) - but the handle_modules_reqdeps() does much more - # which is not needed at this point. # Therefore the algorithms is called directly from here. components = connected_components(r) if components.len() > 1: reqset.info(67, "The resulting graph is not connected. " "Found components: [%s]" % components.as_string()) # Run through all the requirements and check, if there are # requirements which has no incoming. for _, req in r.reqs.iteritems(): if len(req.outgoing) == 0 and req.get_value("Type") != Requirement.rt_master_requirement: print("+++ Info:%s: no outgoing edges" % req.name) return r
def rewrite(self, reqset): components = connected_components(reqset) if components.len() == 1: # Everything is ok: graph is connected return True raise RMTException( 69, "Requirements graph has two or more connected " "components. Please fix the edges between the nodes." "Found components: %s" % components.as_string())
def rmttest_cc_002(self): "Not connected digraph" digraph = Digraph({ "A": ["B"], "B": ["C"], "C": [], "D": ["E"], "E": [] }) ccs = connected_components(digraph) assert ccs.get_length() > 1
def test_cc_002(self): "Not connected digraph" dg = digraph_create_from_dict({ "A": ["B"], "B": ["C"], "C": [], "D": ["E"], "E": [] }) ccs = connected_components(dg) assert (ccs.get_length() > 1)
def rewrite(self, reqset): tracer.debug("Called.") components = connected_components(reqset) if components.get_length() == 1: # Everything is ok: graph is connected tracer.debug("Finished.") return True raise RMTException( 69, "Requirements graph has two or more connected " "components. Please fix the edges between the nodes." "Found components: %s" % components.as_string())
def rewrite(self, reqset): tracer.debug("Called.") components = connected_components(reqset) if components.get_length() == 1: # Everything is ok: graph is connected tracer.debug("Finished.") return True raise RMTException( 69, "Requirements graph has two or more connected " "components. Please fix the edges between the nodes." "Found components: %s" % components.as_string())
def rewrite(reqset): """The rewrite method checks if there is only one connected component. If not an error is printed including all the found components. """ tracer.debug("Called.") components = connected_components(reqset) if components.get_length() == 1: # Everything is ok: graph is connected tracer.debug("Finished.") return True raise RMTException( 69, "Requirements graph has two or more connected " "components. Please fix the edges between the nodes." "Found components: %s" % components.as_string())
def rmttest_cc_001(self): "Connected digraph" digraph = Digraph({"A": ["B"], "B": ["C"], "C": []}) ccs = connected_components(digraph) assert 1 == ccs.get_length()
def rmttest_cc_002(self): "Not connected digraph" digraph = Digraph({"A": ["B"], "B": ["C"], "C": [], "D": ["E"], "E": []}) ccs = connected_components(digraph) assert ccs.get_length() > 1
def rmttest_cc_001(self): "Connected digraph" digraph = Digraph({"A": ["B"], "B": ["C"], "C": []}) ccs = connected_components(digraph) assert 1 == ccs.get_length()
def test_cc_002(self): "Not connected digraph" dg = Digraph( {"A": ["B"], "B": ["C"], "C": [], "D": ["E"], "E": [] } ) ccs = connected_components(dg) assert(ccs.len()>1)
def test_cc_001(self): "Connected digraph" dg = Digraph( {"A": ["B"], "B": ["C"], "C": [] } ) ccs = connected_components(dg) assert(ccs.len()==1)
def test_cc_002(self): "Not connected digraph" dg = digraph_create_from_dict({"A": ["B"], "B": ["C"], "C": [], "D": ["E"], "E": [] }) ccs = connected_components(dg) assert(ccs.get_length() > 1)