Example #1
0
 def matchEndLLR(self,data):
     error_attributes = []
     warning_attributes = []
     debug_attributes = []
     attrs = self.dico_attributes["end"]
     #print "DEBUG DATA",data
     #print "DEBUG ATTRS:",attrs
     if Tool._is_array(attrs):
         for attr in attrs:
             attr_value_found = self.matchAttribute(data,
                                                    attr,
                                                    error_attributes,
                                                    warning_attributes)
             #print "DEBUG attr_value_found:",attr_value_found
             if attr_value_found:
                 break
     else:
         attr_value_found = self.matchAttribute(data,
                                                attrs,
                                                error_attributes,
                                                warning_attributes,
                                                debug_attributes)
     if attr_value_found:
         end_delimiter =attr_value_found
         #self.debug("End delimiter found:{:s}".format(Tool.removeNonAscii(end_delimiter)))
         result = True
     else:
         result = False
     return result
Example #2
0
    def extractAttribute(self,
                         key,
                         line,
                         error_attributes,
                         warning_attributes):

        attrs = self.dico_attributes[key]
        if Tool._is_array(attrs):
            for attr in attrs:
                attr_value_found = self.matchAttribute(line,
                                                       attr,
                                                       error_attributes,
                                                       warning_attributes)
                if attr_value_found:
                    break
        else:
            attr_value_found = self.matchAttribute(line,
                                                   attrs,
                                                   error_attributes,
                                                   warning_attributes)
        if attr_value_found:
            text = Tool.replaceNonASCII(attr_value_found,html=True)
        else:
            text = ""
        return text
Example #3
0
 def getDerived(self,
                type,
                refer,
                derived,
                found_dir,
                start_delimiter,
                key="derived"):
     """
     :param type:
     :param refer:
     :param derived:
     :param found_dir:
     :param start_delimiter:
     :return:
     """
     def isDerived(found,expected):
         found = found.upper()
         expected = expected.upper()
         #print "DERIVED",found,expected
         if found == expected:
             result = True
         else:
             result = False
         return result
     def testPartiallyDerived(refer):
         if refer in ("N/A","EMPTY","NO"):
             result = False
         else:
             result = True
         return result
     # Test derived requirements
     result = False
     #print "DERIVED TYPE",type
     #print "derived",derived
     if type in self.dico_specifications:
         expected_derived_list = self.dico_specifications[type][key]
         #print "expected_derived_list",expected_derived_list
         if Tool._is_array(expected_derived_list):
             for expected_derived in expected_derived_list:
                 result = isDerived(derived,
                                    expected_derived)
                 if result:
                     break
         else:
             result = isDerived(derived,
                                expected_derived_list)
         if result:
             if key == "derived":
                 partially_derived = testPartiallyDerived(refer)
                 if partially_derived:
                     self.dico_errors["derived","S_2",found_dir,start_delimiter,""] = ["Derived requirement with traceability."]
                     self.nb_error += 1
     return result
Example #4
0
    def getPR(self,
              dico_pr,
              detect_in="",
              implemented_for="",
              cr_type="",
              cr_with_parent=False,
              list_cr=[],
              no_header=False,
              list_cr_type=[],
              list_cr_status=[],
              list_cr_doamin=[]):
        """
            Run a Change Request query
            Remove prefix to make generic status name
            The result is put in the table self.tableau_pr with the following columns:
            --------------------------------------------------------------------
            | ID | Synopsis | Type | Status | Detected on | Implemented in/for |
            --------------------------------------------------------------------
            or if parent CR is requested (cr_with_parent = TRUE)
            --------------------------------------------------------------------------------
            | ID | Synopsis | Type | Status | Detected on | Implemented in/for | Parent CR |
            --------------------------------------------------------------------------------
            %CR_type => SW_ENM, SW_BITE, SW_WHCC, SW_PLAN etc...
            Used by CreateCID function

        :param dico_pr: OUTPUT Ex: {"all":[['ID', 'Synopsis', 'Type', 'Status', 'Detected on', 'Implemented in/for', 'Parent CR'],
                                            ['1001', 'Inhibition of TRU over ripple protection', 'Evolution', 'Closed', 'N/A', 'SW_ENM/06', '910'], etc.
        :param detect_in: INPUT
        :param implemented_for: INPUT
        :param cr_type: INPUT
        :param cr_with_parent: INPUT
        """

        # Header
        empty_line = ["--","--","--","--","--","--","--"]
        header = ["ID","Synopsis","Type","Status","Detected on","Implemented in/for","Classif."]
        if cr_with_parent:
            header.append("Parent CR")
            empty_line.append("--")

        tableau_pr          = [] #[header]
        tableau_closed_pr   = [] #[header]
        tableau_opened_pr   = [] #[header]
        if self.ihm is not None:
            # Callback pourri
            old_cr_workflow = False
            condition,detect_attribut = self.new_createConditionStatus(detect_release=detect_in,
                                                                        impl_release=implemented_for,
                                                                        list_cr_type=list_cr_type,
                                                                        list_cr_status=list_cr_status,
                                                                        list_cr_doamin=list_cr_doamin)
        else:
            # Should not be here
            # Patch for input CRs treatment in get_ig_query for IS checking ...
            old_cr_workflow = False
            condition = '"(cvtype=\'problem\') '
            detection_word = "CR_detected_on"
            filter_cr = "CR_implemented_for"
            detect_attribut = "%{:s};%{:s}".format(detection_word,filter_cr)
            if  Tool.isAttributeValid(implemented_for):
                # implemented
                condition += self._createImpl(filter_cr, implemented_for,with_and=True)
            condition += '" '
        cr_domain = ""
        if list_cr != []:
            # overwrite condition previously computed
            query_list_cr = Tool._createImpl("problem_number",list_cr,with_and=False)
            condition = "-t problem \"{:s}\" ".format(query_list_cr)
            cr_domain = "<cell>%CR_domain</cell><cell>%CR_correction_description</cell>"
        if not no_header:
            tableau_pr.append(header)
            tableau_closed_pr.append(header)
            tableau_opened_pr.append(header)

        implementation_baseline_f = "%CR_implementation_baseline"
        # new with tags
        detect_attribut_tag = re.sub(r";","</cell><cell>",detect_attribut)
        classification = CCB.getClassif(old_cr_workflow)
        attributes = '-f "<cell>%problem_number</cell>' \
                     '<cell>%problem_synopsis</cell>' \
                     '<cell>%CR_request_type</cell>' \
                     '<cell>%crstatus</cell>' \
                     '<cell>{:s}</cell>' \
                     '{:s}' \
                     '<cell>%CR_customer_classification</cell>"'.format(detect_attribut_tag,cr_domain)
        # query sorted by CR status
        query = "query -sby crstatus {:s} {:s} ".format(condition,attributes)
        stdout,stderr = self.ccm_query(query,"Get CRs")
        if self.ihm is not None:
            self.ihm.log(query + " completed.")
        else:
            print "getPR query:",query
        # Set scrollbar at the bottom
        list_change_requests = []
        if stdout != "":
            output = stdout.splitlines()
            for line in output:
                line = re.sub(r"<void>",r"",line)
                cr_decod = self._parseCRCell(line)
                print "cr_decod",cr_decod
                cr_id = cr_decod[0]
                cr_synopsis = cr_decod[1]
                type = cr_decod[2]
                cr_domain = self.getCRPrefix(cr_decod[3])
                cr_decod[0] = cr_domain + " " + cr_decod[0]
                cr_decod[3] = self.discardCRPrefix(cr_decod[3])
                status = cr_decod[3]
                detected_on = cr_decod[4]
                implemented_for = cr_decod[5]
                #  Used to fill UI CR list box
                list_change_requests.append("{:s}) {:s}".format(cr_id.zfill(4),cr_synopsis))
                # For CLI
                #print line
                #tableau_pr.append([cr_id,cr_synopsis,type,status,detected_on,implemented_for])
                if cr_with_parent:
                    tbl_parent_cr_id = self._getParentCR(cr_id)
                    #print "tbl_parent_cr_id",tbl_parent_cr_id
                    if tbl_parent_cr_id:
                        #print "tbl_parent_cr_id",tbl_parent_cr_id
                        if Tool._is_array(tbl_parent_cr_id):
                            found_parent_cr_id_str = ", ".join(tbl_parent_cr_id)
                        else:
                            found_parent_cr_id_str = tbl_parent_cr_id
                        cr_decod.extend([found_parent_cr_id_str])
                    else:
                        cr_decod.extend([""])
                else:
                    pass
                    #cr_decod.extend([""])
                tableau_pr.append(cr_decod)
                if status in ("Closed","Fixed","Rejected","Cancelled"):
                    tableau_closed_pr.append(cr_decod)
                else:
                    tableau_opened_pr.append(cr_decod)

        if len(tableau_pr) == 1:
             tableau_pr.append(empty_line)
        if len(tableau_closed_pr) == 1:
             tableau_closed_pr.append(empty_line)
        if len(tableau_opened_pr) == 1:
             tableau_opened_pr.append(empty_line)
        dico_pr["all"]=tableau_pr
        dico_pr["open"]=tableau_opened_pr
        dico_pr["closed"]=tableau_closed_pr
Example #5
0
    def parse_body_attr(self,
                        start_delimiter,    # Requirement ID
                        start,              # Range.Start
                        end,                # Range.End
                        list_attributes = {}):
        """

        :param start_delimiter:
        :param start:
        :param end:
        :param list_attributes:
        :return:
        """
        error_attributes = []
        warning_attributes = []
        #print "START_TAG",start_delimiter,start,end

        for style,key in self.dico_styles.iteritems():
            if key in self.dico_types["SHLVCP"]:
                try:
                    # New Style to be found
                    # range must be reevaluated at each iteration
                    range = self.doc.Range(start,end)
                    index = 0
                    if key == "body":
                        found = True
                    else:
                        found = self.find(range,style=style)

                    while found and index < 50:
                        index += 1
                        line = range.Text
                        if key == "issue":
                            # First attribute
                            parsed_line = self.extractAttribute(key,line,error_attributes,warning_attributes)
                            list_attributes["issue"] = parsed_line
                            if Shlvcp.getVersion(list_attributes["issue"]) == self.doc_version:
                                self.nb_reqs_modified += 1
                            first_attribute_start = range.Start
                            list_attributes["body"] = self.doc.Range(start,first_attribute_start).Text
                            list_procedures = self.getProcInBody(list_attributes["body"])
                            if list_procedures:
                                list_attributes["proc"] = list_procedures
                            objective = self.getObjectiveInBody(list_attributes["body"])
                            if objective:
                                list_attributes["objective"] = re.sub(r"\r","",objective)
                            break
                        elif key == "verify":
                            list_attributes["verify"] = self.getSplitAttribute(line,type="[A-Z]*_[\w-]*")
                            if self.active_dbg:
                                    self.log("Requirement {:s}: Found attribute {:s}:{:s}".format(start_delimiter,
                                                                                                 style,
                                                                                                 list_attributes["verify"]),
                                                                                                 gui_display=True)
                            break
                        elif key == "additional":
                            parsed_line = self.extractAttribute(key,line,error_attributes,warning_attributes)
                            list_attributes["additional"] = parsed_line
                            used_io = self.getUsedIOInBOdy(list_attributes["additional"])
                            if used_io:
                                list_used_io = self.getSplitAttribute(line,type="[A-Z]*_[\w-]*")
                                list_attributes["used_io"] = list_used_io
                                if self.active_dbg:
                                    self.log("Requirement {:s}: Found attribute {:s}:{:s}".format(start_delimiter,
                                                                                                 style,
                                                                                                 list_attributes["used_io"]),
                                                                                                 gui_display=True)
                            break
                        elif key == "body":
                            break
                        else:
                            # remove not related key for SHLVCP
                            attrs = self.dico_attributes[key]
                            if Tool._is_array(attrs):
                                for attr in attrs:
                                    attr_value_found = self.matchAttribute(line,
                                                                           attr,
                                                                           error_attributes,
                                                                           warning_attributes)
                                    if attr_value_found:
                                        break
                            else:
                                attr_value_found = self.matchAttribute(line,
                                                                       attrs,
                                                                       error_attributes,
                                                                       warning_attributes)
                            if range.End == end:
                                # No more attribute with Style is to be found, leave
                                break
                            range = self.doc.Range(range.End,end)
                            # Remove carriage return
                            if attr_value_found:
                                text = Tool.replaceNonASCII(attr_value_found,html=True)
                                if self.active_dbg:
                                    self.log("Requirement {:s}: Found attribute {:s}:{:s}".format(start_delimiter,
                                                                                                 style,
                                                                                                 text),
                                                                                                 gui_display=True)
                                if key not in list_attributes:
                                    list_attributes[key] = text
                                else:
                                    list_attributes[key] += text

                            found = self.find_execute()
                except pythoncom.com_error as exception:
                    print exception
                    print "KEY/Style",key,style