Example #1
0
 def getUsedIOInBOdy(self,data):
     plain_data = Tool.removeNonAscii(data)
     m = re.search(r'Used I/O:(.*)',plain_data)
     if m:
         used_io =m.group(1)
     else:
         used_io = False
     return used_io
Example #2
0
 def getObjectiveInBody(self,data):
     plain_data = Tool.removeNonAscii(data)
     m = re.search(r'Objective:(.*)Test diagram',plain_data)
     if m:
         objective =m.group(1)
     else:
         objective = False
     return objective
Example #3
0
 def getProcInBody(self,data):
     #m = re.match(r'^\s*(.*)', data)
     # Search for test procedures
     plain_data = Tool.removeNonAscii(data)
     list_found_procedures = re.findall(r'SHLVCP_[A-Z_]*_[0-9]{4}_PROC_?[0-9]{0,3}\.bproc',plain_data)
     #self.debug("Body found:{:s}".format(plain_data))
     #self.debug("End Body found")
     return list_found_procedures
Example #4
0
 def getAtribute(dico,attr):
     if attr in dico:
         value = Tool.removeNonAscii(dico[attr])
         # Remove tabulation
         value = re.sub(r"\t",r"",value)
     else:
         value = "None"
     return value
Example #5
0
 def matchAttribute(self,
                    data,
                    attr,
                    error_attributes=[],
                    warning_attributes=[],
                    debug_attributes=[]):
     #print "Atribute selected:",attr,
     m = re.match("^\s*" + attr + "\s*(.*)", data)
     if m:
         attr_value_found = m.group(1)
         self.debug("Attributes found {:s} {:s}".format(attr,Tool.removeNonAscii(attr_value_found)))
         #print "Attributes found ",attr,attr_value_found
         # test semi colon presence
         m = re.search(';', attr_value_found)
         if m:
             value_filtered = re.sub(r";",r",",attr_value_found)
             debug_attributes.append("Unexpected semi-colon found in \"{:s}\" attribute.".format(attr))
             #print "ERROR",error
         else:
             value_filtered = attr_value_found
         # test missing missing comma in "Refer to" attribute
         if attr == "Refers to:" or attr == "Constraint by:":
             char = {r'\t':'',r' ':''}
             for before, after in char.iteritems():
                 value_filtered = re.sub(before,after,value_filtered)
             #print "TEST:",attr_value_found
             # Find double brackets
             m = re.search(r'\]\]', value_filtered)
             if m:
                 error_attributes.append("Double brackets in {:s} attribute.".format(attr))
                 value_filtered = re.sub(r"\]\]",r"]",value_filtered)
             m = re.search(r'\[\[', value_filtered)
             if m:
                 error_attributes.append("Double brackets in  {:s} attribute.".format(attr))
                 value_filtered = re.sub(r"\[\[",r"[",value_filtered)
             m = re.match(r'^\[(.*)\]', value_filtered)
             if m:
                 inside_brackets = m.group(1)
                 # Between brackets
                 # Find brackets without separator
                 m = re.match(r'(.*)\] ?\[(.*)', inside_brackets)
                 if m:
                     debug_attributes.append("Missing comma in \"{:s}\" attribute.".format(attr))
                     result = re.sub(r"\] ?\[",r"],[",value_filtered)
                 else:
                     result = value_filtered
                 #print "TEST2:",result
             else:
                 result = value_filtered
         else:
             result = value_filtered
         if result == "":
             result = "EMPTY"
     else:
         #print "UNKNOWN:",data
         result = False
     return result
Example #6
0
 def matchBegin(self,
                data,
                type):
    # print "DEBUG DATA:",data
     if data not in (None,0):
         # Regex
         # \s : Matches any whitespace character like a blank space, tab, and the like.
         m = re.match(r'^\s*\[({:s}.*)\]'.format(type), data)
         if m:
             start_delimiter = m.group(1)
             #print "DEBUG start_delimiter:",start_delimiter
             self.debug("Start delimiter found:{:s} beginning with {:s}".format(Tool.removeNonAscii(start_delimiter),type))
             result = start_delimiter
         else:
             result = False
     else:
         result = False
     return result
Example #7
0
 def parse_end_req(self,
                   tbl_req=[],       # Input
                   tbl_output=[]):   # Output
     iter_list = iter(tbl_req)
     myRange = self.doc.Content
     sel = self.doc.Application.Selection
     found = self.find(myRange,style='REQ_End')
     start_first_req_part =  myRange.Start
     if not found:
         print "Missing REQ_End style in document."
         print "Start:",myRange.Start
         print "End:",myRange.End
     req_id = "0"
     while found:
         error = False
         txt = myRange.Text
         #m = re.match(r'^\s*\[End Requirement\]',txt)
         m = self.matchEndLLR(txt)
         if m:
             # Style is coherent with tag text
             self.debug("Found REQ_end: {:s}".format(txt))
             start_req_end = myRange.Start
             end_req_end = myRange.End
         else:
             self.debug("Style is not coherent with tag text: {:s}".format(Tool.removeNonAscii(txt)))
             error = True
         try:
             req_id,start_tag,end_tag = iter_list.next()
             if not error:
                 tbl_output.append((req_id,end_tag,end_req_end))
             #print "REQ:",req_id,start,end_req_end
             #print "TXT:",txt
             found = self.find_execute()
         except StopIteration:
             print "End iterations on requirement {:s}".format(req_id)
             # End of iteration
             break
     end_req_part = myRange.End
     return end_req_part