def requirement(self, req): '''Output the given requirement.''' desc = LaTeXMarkup.replace_txt( req.get_value("Description").get_content()) priority = req.get_value("Priority") effort = "n/a" if req.is_val_av_and_not_null("Effort estimation"): effort = req.get_value("Effort estimation") status = "" if req.is_val_av_and_not_null("Status"): status = req.get_value("Status").get_output_string() testcases = "" if req.is_val_av_and_not_null("Test Cases"): testcases = req.get_value("Test Cases") rationale = "" if req.is_val_av_and_not_null("Rationale"): rationale = LaTeXMarkup.replace_txt( req.get_value("Rationale").get_content()) self.__fd.write('requirement,"%s",%4.3f,"%s","%s","%s","%s","%s"\n' % (status, priority, effort, req.get_id(), desc, rationale, ", ".join(testcases)))
def requirement(self, req): '''Output the given requirement.''' # There is the need for a unique numeric id xml_task = self.__xml_doc.createElement("task") xml_task.setAttribute("name", req.get_name()) xml_task.setAttribute("id", str(self.get_req_id(req.get_name()))) if req.get_requirement().is_val_av_and_not_null("Effort estimation"): # The Effort Estimation is only rounded: ganntproject can # only handle integers as duration xml_task.setAttribute( "duration", str(int(req.get_requirement().get_value("Effort estimation") * self.effort_factor + 1))) # The Status (a la complete) must be given in percent. # Currently rmtoo supports only two states: not done (~0) or # finished (~100) if req.get_requirement().is_val_av_and_not_null("Status"): complete_val = "0" if isinstance(req.get_requirement().get_status(), RequirementStatusFinished): complete_val = "100" elif isinstance(req.get_requirement().get_status(), RequirementStatusAssigned): complete_val = "50" xml_task.setAttribute("complete", complete_val) # Notes # Add the description and if available also the rationale and # note. notes = "== Description ==\n" notes += LaTeXMarkup.replace_txt(req.get_requirement().get_value("Description") .get_content()) if req.get_requirement().is_val_av_and_not_null("Rationale"): notes += "\n\n== Rationale ==\n" notes += LaTeXMarkup.replace_txt( req.get_requirement().get_value("Rationale").get_content()) if req.get_requirement().is_val_av_and_not_null("Note"): notes += "\n\n== Note ==\n" notes += LaTeXMarkup.replace_txt(req.get_requirement().get_value("Note") .get_content()) xml_note = self.__xml_doc.createElement("notes") xml_text = self.__xml_doc.createCDATASection(notes) xml_note.appendChild(xml_text) xml_task.appendChild(xml_note) # Dependencies for node in req.get_iter_outgoing(): xml_depend = self.__xml_doc.createElement("depend") xml_depend.setAttribute("id", str(self.get_req_id(node.get_name()))) # There are some default attrs xml_depend.setAttribute("type", "2") xml_depend.setAttribute("difference", "0") xml_depend.setAttribute("hardness", "Strong") xml_task.appendChild(xml_depend) self.__xml_obj_stack[-1].appendChild(xml_task)
def analyse(lwords, text): # Must be at least some positive things to get this # positive. (An empty description is a bad one.) level = -10 log = [] for wre, wlvl, wdsc in lwords: plain_txt = LaTeXMarkup.replace_txt(text).strip() fal = len(wre.findall(plain_txt)) if fal>0: level += fal*wlvl log.append("%+4d:%d*%d: %s" % (fal*wlvl, fal, wlvl, wdsc)) # Note the result of this test in the requirement itself. return [level, log]
def analyse(lname, lwords, text): # print("ANALYSE: [%s]" % text) # Must be at least some positive things to get this # positive. (An empty description is a bad one.) level = -10 log = [] for wre, wlvl, wdsc in lwords: plain_txt = LaTeXMarkup.replace_txt(text).strip() fal = len(wre.findall(plain_txt)) if fal > 0: level += fal * wlvl log.append("%+4d:%d*%d: %s" % (fal * wlvl, fal, wlvl, wdsc)) # Note the result of this test in the requirement itself. return Result('DescWords', lname, level, log)
def analyse(lname, lwords, text): print("ANALYSE: [%s]" % text) # Must be at least some positive things to get this # positive. (An empty description is a bad one.) level = -10 log = [] for wre, wlvl, wdsc in lwords: plain_txt = LaTeXMarkup.replace_txt(text).strip() fal = len(wre.findall(plain_txt)) if fal > 0: level += fal * wlvl log.append("%+4d:%d*%d: %s" % (fal * wlvl, fal, wlvl, wdsc)) # Note the result of this test in the requirement itself. # TODO: Use Object for this! return Result('DescWords', lname, level, log)
def output_html_topic_output_content(self, fd, topic): # Subtopics go in a ul ul_open = False for t in topic.t: tag = t.get_tag() val = t.get_content() if tag != "SubTopic" and ul_open: fd.write("</ul></span>") ul_open = False if tag == "Name": # The Name itself depends on the level. fd.write("<h%d>%s</h%d>\n" % (topic.level+1, val, topic.level+1)) continue if tag == "SubTopic": if not ul_open: fd.write('<span class="subtopiclist"><ul>') ul_open = True rtopic = topic.find_outgoing(val) # A link to the other file. fd.write('<li><a href="%s.html">%s</a></li>\n' % (val, rtopic.get_name())) self.output_html_topic(rtopic) continue if tag == "Text": fd.write('<p><span class="fltext">%s</span></p>\n' % LaTeXMarkup.replace_html(val)) continue if tag == "IncludeRequirements": self.output_requirements(fd, topic) continue if ul_open: fd.write("</ul></span>")
def output_html_topic_output_content(self, fd, topic): # Subtopics go in a ul ul_open = False for t in topic.get_tags(): tag = t.get_tag() val = t.get_content() if tag != "SubTopic" and ul_open: fd.write("</ul></span>") ul_open = False if tag == "Name": # The Name itself depends on the level. fd.write("<h%d>%s</h%d>\n" % (topic.level + 1, val, topic.level + 1)) continue if tag == "SubTopic": if not ul_open: fd.write('<span class="subtopiclist"><ul>') ul_open = True rtopic = topic.find_incoming(val) # A link to the other file. fd.write('<li><a href="%s.html">%s</a></li>\n' % (val, rtopic.get_name())) self.output_html_topic(rtopic) continue if tag == "Text": fd.write('<p><span class="fltext">%s</span></p>\n' % LaTeXMarkup.replace_html(val)) continue if tag == "IncludeRequirements": self.output_requirements(fd, topic) continue if ul_open: fd.write("</ul></span>")
def output_requirement(self, fd, req, level): fd.write("\n<!- REQ '%s' -->\n" % req.id) fd.write('<h%d><a name="%s">%s</a></h%d>\n' % (level+1, req.id, req.get_value("Name").get_content(), level+1)) fd.write("<dl>") fd.write('<dt><span class="dlt_description">Description</span>' '</dt><dd><span class="dlv_description">%s</span></dd>' % LaTeXMarkup.replace_html(req.get_value("Description") .get_content())) if req.is_value_available("Rationale") \ and req.get_value("Rationale")!=None: fd.write('<dt><span class="dlt_rationale">Rationale</span>' '</dt><dd><span class="dlv_rationale">%s</span></dd>' % LaTeXMarkup.replace_html_par(req.get_value("Rationale"). get_content())) if req.is_value_available("Note") and req.get_value("Note")!=None: fd.write('<dt><span class="dlt_note">Note</span></dt>' '<dd><span class="dlv_note">%s</span></dd>' % req.get_value("Note").get_content()) # Only output the depends on when there are fields for output. if len(req.outgoing)>0: # Create links to the corresponding labels. fd.write('<dt><span class="dlt_depends_on">Depends on:' '</span></dt><dd><span class="dlv_depends_on"') is_first = True for d in req.outgoing: if not is_first: fd.write(", ") is_first=False fd.write('<a href="%s.html#%s">%s</a>' % (d.get_value("Topic"), d.id, d.id)) fd.write("</span></dd>") if len(req.incoming)>0: # Create links to the corresponding dependency nodes. fd.write('<dt><span class="dlt_dependent">Dependent' '</span></dt><dd><span class="dlv_dependent">') is_first = True for d in req.incoming: if not is_first: fd.write(", ") is_first=False fd.write('<a href="%s.html#%s">%s</a>' % (d.get_value("Topic"), d.id, d.id)) fd.write("</span></dd>") status = req.get_value("Status").get_output_string() clstr = req.get_value("Class").get_output_string() fd.write('<dt><span class="dlt_id">Id</span></dt>' '<dd><span class="dlv_id">%s</span></dd>' '<dt><span class="dlt_priority">Priority</span></dt>' '<dd><span class="dlv_priority">%4.2f</span></dd>' '<dt><span class="dlt_owner">Owner</span></dt>' '<dd><span class="dlv_owner">%s</span></dd>' '<dt><span class="dlt_invented_on">Invented on</span></dt>' '<dd><span class="dlv_invented_on">%s</span></dd>' '<dt><span class="dlt_invented_by">Invented by</span></dt>' '<dd><span class="dlv_invented_by">%s</span></dd>' '<dt><span class="dlt_status">Status</span></dt>' '<dd><span class="dlv_status">%s</span></dd>' '<dt><span class="dlt_class">Class</span></dt>' '<dd><span class="dlv_class">%s</span></dd>' % (req.id, req.get_value("Priority")*10, req.get_value("Owner"), req.get_value("Invented on").strftime("%Y-%m-%d"), req.get_value("Invented by"), status, clstr)) fd.write("</dl>") # Mark the end of the requirment - then it is possible to add # some ruler here fd.write('<div class="requirment_end"> </div>')
def topic_text(self, text): '''Called when there is text to be outputted.''' fd = self.__fd_stack[-1] fd.write('<p><span class="fltext">%s</span></p>\n' % LaTeXMarkup.replace_html(text))
def requirement(self, req): '''Output one requirement.''' fd = self.__fd_stack[-1] level = len(self.__fd_stack) fd.write("\n<!- REQ '%s' -->\n" % req.get_name()) fd.write( '<h%d><a name="%s">%s</a></h%d>\n' % (level + 1, req.get_name(), req.get_requirement().get_value("Name").get_content(), level + 1)) fd.write("<dl>") fd.write( '<dt><span class="dlt_description">Description</span>' '</dt><dd><span class="dlv_description">%s</span></dd>' % LaTeXMarkup.replace_html( req.get_requirement().get_value("Description").get_content())) if req.get_requirement().is_value_available("Rationale") \ and req.get_requirement().get_value("Rationale") != None: fd.write( '<dt><span class="dlt_rationale">Rationale</span>' '</dt><dd><span class="dlv_rationale">%s</span></dd>' % LaTeXMarkup.replace_html_par(req.get_requirement().get_value( "Rationale").get_content())) if req.get_requirement().is_value_available("Note") \ and req.get_requirement().get_value("Note") != None: fd.write('<dt><span class="dlt_note">Note</span></dt>' '<dd><span class="dlv_note">%s</span></dd>' % req.get_requirement().get_value("Note").get_content()) # Only output the depends on when there are fields for output. if req.get_outgoing_cnt() > 0: # Create links to the corresponding labels. fd.write('<dt><span class="dlt_depends_on">Depends on:' '</span></dt><dd><span class="dlv_depends_on">') is_first = True for d in sorted(req.get_iter_outgoing(), key=lambda r: r.get_name()): if not is_first: fd.write(", ") is_first = False fd.write('<a href="%s.html#%s">%s</a>' % (d.get_requirement().get_value("Topic"), d.get_name(), d.get_name())) fd.write("</span></dd>") if req.get_incoming_cnt() > 0: # Create links to the corresponding dependency nodes. fd.write('<dt><span class="dlt_dependent">Dependent' '</span></dt><dd><span class="dlv_dependent">') is_first = True for d in sorted(req.get_iter_incoming(), key=lambda r: r.get_name()): if not is_first: fd.write(", ") is_first = False fd.write('<a href="%s.html#%s">%s</a>' % (d.get_requirement().get_value("Topic"), d.get_name(), d.get_name())) fd.write("</span></dd>") status = req.get_requirement().get_value("Status").get_output_string() clstr = req.get_requirement().get_value("Class").get_output_string() fd.write( '<dt><span class="dlt_id">Id</span></dt>' '<dd><span class="dlv_id">%s</span></dd>' '<dt><span class="dlt_priority">Priority</span></dt>' '<dd><span class="dlv_priority">%4.2f</span></dd>' '<dt><span class="dlt_owner">Owner</span></dt>' '<dd><span class="dlv_owner">%s</span></dd>' '<dt><span class="dlt_invented_on">Invented on</span></dt>' '<dd><span class="dlv_invented_on">%s</span></dd>' '<dt><span class="dlt_invented_by">Invented by</span></dt>' '<dd><span class="dlv_invented_by">%s</span></dd>' '<dt><span class="dlt_status">Status</span></dt>' '<dd><span class="dlv_status">%s</span></dd>' '<dt><span class="dlt_class">Class</span></dt>' '<dd><span class="dlv_class">%s</span></dd>' % (req.get_name(), req.get_requirement().get_value("Priority") * 10, req.get_requirement().get_value("Owner"), req.get_requirement(). get_value("Invented on").strftime("%Y-%m-%d"), req.get_requirement().get_value("Invented by"), status, clstr)) fd.write("</dl>") # Mark the end of the requirment - then it is possible to add # some ruler here fd.write('<div class="requirment_end"> </div>')
def requirement(self, req): '''Output the given requirement.''' # There is the need for a unique numeric id xml_task = self.__xml_doc.createElement("task") xml_task.setAttribute("name", req.get_name()) xml_task.setAttribute("id", str(self.get_req_id(req.get_name()))) if req.get_requirement().is_val_av_and_not_null("Effort estimation"): # The Effort Estimation is only rounded: ganntproject can # only handle integers as duration xml_task.setAttribute( "duration", str( int(req.get_requirement().get_value("Effort estimation") * self.effort_factor + 1))) # The Status (a la complete) must be given in percent. # Currently rmtoo supports only two states: not done (~0) or # finished (~100) if req.get_requirement().is_val_av_and_not_null("Status"): complete_val = "0" if isinstance(req.get_requirement().get_status(), RequirementStatusFinished): complete_val = "100" elif isinstance(req.get_requirement().get_status(), RequirementStatusAssigned): complete_val = "50" xml_task.setAttribute("complete", complete_val) # Notes # Add the description and if available also the rationale and # note. notes = "== Description ==\n" notes += LaTeXMarkup.replace_txt( req.get_requirement().get_value("Description").get_content()) if req.get_requirement().is_val_av_and_not_null("Rationale"): notes += "\n\n== Rationale ==\n" notes += LaTeXMarkup.replace_txt( req.get_requirement().get_value("Rationale").get_content()) if req.get_requirement().is_val_av_and_not_null("Note"): notes += "\n\n== Note ==\n" notes += LaTeXMarkup.replace_txt( req.get_requirement().get_value("Note").get_content()) xml_note = self.__xml_doc.createElement("notes") xml_text = self.__xml_doc.createCDATASection(notes) xml_note.appendChild(xml_text) xml_task.appendChild(xml_note) # Dependencies for node in req.get_iter_outgoing(): xml_depend = self.__xml_doc.createElement("depend") xml_depend.setAttribute("id", str(self.get_req_id(node.get_name()))) # There are some default attrs xml_depend.setAttribute("type", "2") xml_depend.setAttribute("difference", "0") xml_depend.setAttribute("hardness", "Strong") xml_task.appendChild(xml_depend) self.__xml_obj_stack[-1].appendChild(xml_task)