コード例 #1
0
ファイル: TxtParser.py プロジェクト: florath/rmtoo
 def split_entries(split_lines, rid, mls, lineno_offset):
     '''This method splits up the given string in seperate entries which
     represent a entry record each.
     The lineno offset is the line number of the first line given in
     the sl array.
     '''
     doc = []
     lineno = lineno_offset
     success = True
     while split_lines:
         try:
             next_record \
                 = TxtParser.split_next_record(
                     split_lines, rid, lineno, mls)
             doc.append(next_record)
             lineno += len(next_record[1]) + len(next_record[2])
         except RMTException as rmte:
             # This is a hint that the tag line could not correctly
             # parsed.
             logger.error(LogFormatter.rmte(rmte))
             # Remove the errornous line
             del split_lines[0]
             lineno += 1
             success = False
     return success, doc
コード例 #2
0
 def split_entries(split_lines, rid, mls, lineno_offset):
     '''This method splits up the given string in seperate entries which
     represent a entry record each.
     The lineno offset is the line number of the first line given in
     the sl array.
     '''
     doc = []
     lineno = lineno_offset
     success = True
     while split_lines:
         try:
             next_record \
                 = TxtParser.split_next_record(
                     split_lines, rid, lineno, mls)
             doc.append(next_record)
             lineno += len(next_record[1]) + len(next_record[2])
         except RMTException as rmte:
             # This is a hint that the tag line could not correctly
             # parsed.
             logger.error(LogFormatter.rmte(rmte))
             # Remove the errornous line
             del split_lines[0]
             lineno += 1
             success = False
     return success, doc
コード例 #3
0
ファイル: RequirementSet.py プロジェクト: samjaninf/rmtoo
    def __resolve_depends_on_one_req(self, req_node, also_solved_by):
        tracer.debug("Called.")
        req = req_node.get_requirement()
        if req.get_value("Type") == Requirement.rt_master_requirement:
            # There must no 'Depends on'
            if "Depends on" in req.brmo:
                print("+++ ERROR %s: initial requirement has "
                      "Depends on field." % (req.id))
                return False
            # It self does not have any depends on nodes
            req.graph_depends_on = None
            # This is the master!
            return True

        # For all other requirements types there must be a 'Depends on'
        if "Depends on" not in req.brmo:
            if also_solved_by:
                # Skip handling this requirement
                return True
            print("+++ ERROR %s: non-initial requirement has "
                  "no 'Depends on' field." % (req.id))
            return False

        t = req.brmo["Depends on"]

        # If available, it must not empty
        if len(t.get_content()) == 0:
            print("+++ ERROR %s: 'Depends on' field has len 0" % (req.id))
            return False

        # Step through the list
        tl = t.get_content().split()
        for ts in tl:
            if ts not in self.get_all_requirement_ids():
                logger.error(
                    LogFormatter.format(
                        47, "'Depends on' points to a "
                        "non-existing requirement '%s'" % ts, req.id))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if ts == req.id:
                logger.error(
                    LogFormatter.format(
                        59, "'Depends on' points to the "
                        "requirement itself", req.id))
                return False

            # Mark down the depends on...
            dep_req_node = self._named_nodes[ts]
            # This is exactly the other way as used in the 'Depends on'
            tracer.debug(
                "Add edge [%s] -> [%s]" %
                (dep_req_node.get_requirement().get_id(), req.get_id()))
            Digraph.create_edge(self, dep_req_node, req_node)

        # Copy and delete the original tag
        ## XXX Not neede any more? req.tags["Depends on"] = t.split()
        del req.brmo["Depends on"]
        return True
コード例 #4
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
    def _handle_modules(self, input_mods):
        '''Handle all modules which are executed on the 
           requirement set level.
           (One '_' only because this is used by the unit tests.'''
        tracer.debug("Called.")
        # Dependencies can be done, if all requirements are successfully
        # read in.
        self.__handle_modules_reqdeps(input_mods)
        # If there was an error, the state flag is set:
        tracer.debug("Check usability.")
        if not self.is_usable():
            logger.error(LogFormatter.format(
                       43, "there was a problem handling the "
                       "requirement set modules"))
            return False

        # The must no be left
        tracer.debug("Check all handled.")
        if not self.__all_tags_handled():
            logger.error(LogFormatter.format(
                       56, "There were errors encountered during parsing "
                       "and checking - can't continue."))
            return False

        return True
コード例 #5
0
    def __read_one_requirement(self, fileinfo, input_mods, object_cache):
        '''Read in one requirement from the file info.'''
        tracer.debug("Called.")
        # Check for correct filename
        if not fileinfo.get_filename().endswith(".req"):
            tracer.info("skipping file [%s]", fileinfo.get_filename())
            return
        # Handle caching.
        vcs_id = fileinfo.get_vcs_id()
        rid = fileinfo.get_filename_sub_part()[:-4]
        req = object_cache.get("Requirement", vcs_id)
        tracer.info("Reading requirement [%s]", rid)

        if req is None:
            file_content = fileinfo.get_content()
            req = Requirement(file_content, rid, fileinfo.get_filename(),
                              input_mods, self._config)
            # Add the requirement to the cache.
            object_cache.add(vcs_id, "Requirement", req)

        self._adapt_usablility(req)

        if req.is_usable():
            # Store in the map, so that it is easy to access the
            # node by id.
            self.add_requirement(req)
            # Also store it in the digraph's node list for simple
            # access to the digraph algorithms.
            # self.nodes.append(req)
        else:
            logger.error(LogFormatter.format(
                45, "could not be parsed", req.get_id()))
        tracer.debug("Finished.")
コード例 #6
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
    def __read_one_requirement(self, fileinfo, input_mods, object_cache):
        '''Read in one requirement from the file info.'''
        tracer.debug("Called.")
        # Check for correct filename
        if not fileinfo.get_filename().endswith(".req"):
            tracer.info("skipping file [%s]" % fileinfo.get_filename())
            return
        # Handle caching.
        vcs_id = fileinfo.get_vcs_id()
        rid = fileinfo.get_filename_sub_part()[:-4]
        req = object_cache.get("Requirement", vcs_id)
        tracer.info("Reading requirement [%s]" % rid)

        if req == None:
            file_content = fileinfo.get_content()
            req = Requirement(file_content, rid, fileinfo.get_filename(),
                              input_mods, self._config)
            # Add the requirement to the cache.
            object_cache.add(vcs_id, "Requirement", req)

        self._adapt_usablility(req)

        if req.is_usable():
            dnreq = RequirementDNode(req)
            # Store in the map, so that it is easy to access the
            # node by id.
### ToDo: needed            self._add_requirement(req)
            self.add_node(dnreq)
            # Also store it in the digraph's node list for simple
            # access to the digraph algorithms.
            # self.nodes.append(req)
        else:
            logger.error(LogFormatter.format(
                45, "could not be parsed", req.id))
        tracer.debug("Finished.")
コード例 #7
0
    def __resolve_depends_on_one_req_impl(self, req):
        tag_content = req.brmo["Depends on"]

        # If available, it must not empty
        if not tag_content.get_content():
            print("+++ ERROR %s: 'Depends on' field has len 0" %
                  (req.get_id()))
            return False

        # Step through the list
        tag_content_split = tag_content.get_content().split()
        for split_tag in tag_content_split:
            if split_tag not in self.get_all_requirement_ids():
                logger.error(LogFormatter.format(
                    47, "'Depends on' points to a "
                    "non-existing requirement '%s'" % split_tag, req.get_id()))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if split_tag == req.get_id():
                logger.error(LogFormatter.format(
                    59, "'Depends on' points to the "
                    "requirement itself", req.get_id()))
                return False

            # Mark down the depends on...
            dep_req = self.__requirements[split_tag]
            # This is exactly the other way as used in the 'Depends on'
            tracer.debug("Add edge [%s] -> [%s]",
                         dep_req.get_id(), req.get_id())
            Digraph.create_edge(dep_req, req)
        # Delete the original tag
        del req.brmo["Depends on"]
        return True
コード例 #8
0
    def _handle_modules(self, input_mods):
        '''Handle all modules which are executed on the
           requirement set level.
           (One '_' only because this is used by the unit tests.'''
        tracer.debug("Called.")
        # Dependencies can be done, if all requirements are successfully
        # read in.
        self.__handle_modules_reqdeps(input_mods)
        # If there was an error, the state flag is set:
        tracer.debug("Check usability.")
        if not self.is_usable():
            logger.error(LogFormatter.format(
                43, "there was a problem handling the "
                "requirement set modules"))
            return False

        # The must no be left
        tracer.debug("Check all handled.")
        if not self.__all_tags_handled():
            logger.error(LogFormatter.format(
                56, "There were errors encountered during parsing "
                "and checking - can't continue."))
            return False

        return True
コード例 #9
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
    def __read_one_testcase(self, fileinfo, input_mods, object_cache):
        '''Read in one testcase from the file info.'''
        tracer.debug("Called.")
        # Check for correct filename
        if not fileinfo.get_filename().endswith(".tec"):
            tracer.info("skipping file [%s]" % fileinfo.get_filename())
            return
        # Handle caching.
        vcs_id = fileinfo.get_vcs_id()
        rid = fileinfo.get_filename_sub_part()[:-4]
        testcase = object_cache.get("TestCase", vcs_id)
        tracer.info("Reading testcase [%s]" % rid)

        if testcase == None:
            file_content = fileinfo.get_content()
            testcase = TestCase(file_content, rid, fileinfo.get_filename(),
                                input_mods, self._config)
            # Add the requirement to the cache.
            object_cache.add(vcs_id, "TestCase", testcase)

        self._adapt_usablility(testcase)

        if testcase.is_usable():
            # Store in the map, so that it is easy to access the
            # node by id.
            self._add_testcase(testcase)
            # Also store it in the digraph's node list for simple
            # access to the digraph algorithms.
            # self.nodes.append(req)
        else:
            logger.error(LogFormatter.format(
                115, "could not be parsed", testcase.id))
        tracer.debug("Finished.")
コード例 #10
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
    def __resolve_depends_on_one_req(self, req_node, also_solved_by):
        tracer.debug("Called.")
        req = req_node.get_requirement()
        if req.get_value("Type") == Requirement.rt_master_requirement:
            # There must no 'Depends on'
            if "Depends on" in req.brmo:
                print("+++ ERROR %s: initial requirement has "
                      "Depends on field." % (req.id))
                return False
            # It self does not have any depends on nodes
            req.graph_depends_on = None
            # This is the master!
            return True

        # For all other requirements types there must be a 'Depends on'
        if "Depends on" not in req.brmo:
            if also_solved_by:
                # Skip handling this requirement
                return True
            print("+++ ERROR %s: non-initial requirement has "
                  "no 'Depends on' field." % (req.id))
            return False

        t = req.brmo["Depends on"]

        # If available, it must not empty
        if len(t.get_content()) == 0:
            print("+++ ERROR %s: 'Depends on' field has len 0" %
                  (req.id))
            return False

        # Step through the list
        tl = t.get_content().split()
        for ts in tl:
            if ts not in self.get_all_requirement_ids():
                logger.error(LogFormatter.format(
                             47, "'Depends on' points to a "
                             "non-existing requirement '%s'" % ts, req.id))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if ts == req.id:
                logger.error(LogFormatter.format(
                      59, "'Depends on' points to the "
                      "requirement itself", req.id))
                return False

            # Mark down the depends on...
            dep_req_node = self._named_nodes[ts]
            # This is exactly the other way as used in the 'Depends on'
            tracer.debug("Add edge [%s] -> [%s]" %
                         (dep_req_node.get_requirement().get_id(),
                          req.get_id()))
            Digraph.create_edge(self, dep_req_node, req_node)

        # Copy and delete the original tag
        ## XXX Not neede any more? req.tags["Depends on"] = t.split()
        del req.brmo["Depends on"]
        return True
コード例 #11
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
 def __all_tags_handled(self):
     '''Returns true iff all the different tags are handled.'''
     all_handled = True
     for req_node in self.get_iter_nodes_values():
         req = req_node.get_requirement()
         if len(req.brmo) > 0:
             logger.error(LogFormatter.format(
                        57, "No tag handler found for tag(s) '%s' "
                        "- Hint: typo in tag(s)?" % req.brmo.keys(),
                        req.get_id()))
             all_handled = False
     return all_handled
コード例 #12
0
 def __all_tags_handled(self):
     '''Returns true iff all the different tags are handled.'''
     all_handled = True
     for req in self.nodes:
         if req.brmo:
             logger.error(LogFormatter.format(
                 57, "No tag handler found for tag(s) '%s' "
                 "- Hint: typo in tag(s)?"
                 % json.dumps(list(req.brmo.keys())),
                 req.get_id()))
             all_handled = False
     return all_handled
コード例 #13
0
ファイル: TxtRecord.py プロジェクト: samjaninf/rmtoo
 def check_line_length(self, sl, rid):
     max_line_length = self.tioconfig.get_max_line_length()
     lineno = 0
     for l in sl:
         lineno += 1
         if len(l) > max_line_length:
             logger.error(
                 LogFormatter.format(
                     80, "line too long: is [%d], "
                     "max allowed [%d]" % (len(l), max_line_length), rid,
                     lineno))
             self._set_not_usable()
コード例 #14
0
 def check_line_length(self, split_lines, rid):
     """Check if the given lines are too long (or not)"""
     max_line_length = self.tioconfig.get_max_line_length()
     lineno = 0
     for line in split_lines:
         lineno += 1
         if len(line) > max_line_length:
             logger.error(
                 LogFormatter.format(
                     80, "line too long: is [%d], "
                     "max allowed [%d]" % (len(line), max_line_length), rid,
                     lineno))
             self._set_not_usable()
コード例 #15
0
ファイル: RequirementSet.py プロジェクト: samjaninf/rmtoo
 def __all_tags_handled(self):
     '''Returns true iff all the different tags are handled.'''
     all_handled = True
     for req_node in self.get_iter_nodes_values():
         req = req_node.get_requirement()
         if len(req.brmo) > 0:
             logger.error(
                 LogFormatter.format(
                     57, "No tag handler found for tag(s) '%s' "
                     "- Hint: typo in tag(s)?" % req.brmo.keys(),
                     req.get_id()))
             all_handled = False
     return all_handled
コード例 #16
0
ファイル: BaseRMObject.py プロジェクト: samjaninf/rmtoo
    def handle_modules_tag(self, reqs):
        if self.mods == None:
            return

        for modkey, module in self.mods.get_tagtype(self.tbhtags).items():
            try:
                tracer.debug("handle modules tag modkey [%s] tagtype [%s]"
                      % (modkey, self.tbhtags))
                if self.tbhtags not in module.get_type_set():
                    logger.error(LogFormatter.format(
                                 90, "Wrong module type [%s] not in [%s]" %
                                 (self.tbhtags, module.get_type_set())))
                    continue
                key, value = module.rewrite(self.id, reqs)
                # Check if there is already a key with the current key
                # in the map.
                if key in self.values:
                    logger.error(LogFormatter.format(
                          54, "tag [%s] already defined" %
                          (key), self.id))
                    self._set_not_usable()
                    # Also continue to get possible further error
                    # messages.
                self.values[key] = value
            except RMTException, rmte:
                # Some semantic error occurred: do not interpret key or
                # value.
                logger.error(LogFormatter.rmte(rmte))
                logger.error(LogFormatter.format(
                               41, "semantic error occurred in "
                               "module [%s]" % modkey, self.id))
                self._set_not_usable()
コード例 #17
0
ファイル: BaseRMObject.py プロジェクト: isaacde/rmtoo
    def handle_modules_tag(self, reqs):
        if self.mods == None:
            return

        for modkey, module in self.mods.get_tagtype(self.tbhtags).items():
            try:
                tracer.debug("handle modules tag modkey [%s] tagtype [%s]" % (modkey, self.tbhtags))
                if self.tbhtags not in module.get_type_set():
                    logger.error(
                        LogFormatter.format(
                            90, "Wrong module type [%s] not in [%s]" % (self.tbhtags, module.get_type_set())
                        )
                    )
                    continue
                key, value = module.rewrite(self.id, reqs)
                # Check if there is already a key with the current key
                # in the map.
                if key in self.values:
                    logger.error(LogFormatter.format(54, "tag [%s] already defined" % (key), self.id))
                    self._set_not_usable()
                    # Also continue to get possible further error
                    # messages.
                self.values[key] = value
            except RMTException, rmte:
                # Some semantic error occurred: do not interpret key or
                # value.
                logger.error(LogFormatter.rmte(rmte))
                logger.error(LogFormatter.format(41, "semantic error occurred in " "module [%s]" % modkey, self.id))
                self._set_not_usable()
コード例 #18
0
    def __read_one_constraint(self, fileinfo, input_mods, object_cache):
        '''Read in one constraints from the file info.'''
        result = self.__read_one_element(fileinfo, input_mods, object_cache,
                                         ".ctr", "Constraint")
        if result is None:
            return

        if result.is_usable():
            # Store in the map, so that it is easy to access the
            # node by id.
            self.add_constraint(result)
            # Also store it in the digraph's node list for simple
            # access to the digraph algorithms.
            # self.nodes.append(req)
        else:
            logger.error(LogFormatter.format(87, "could not be parsed",
                                             result.get_id()))
コード例 #19
0
    def __resolve_solved_by_one_req_deps(self, req):
        content = req.brmo["Solved by"].get_content()
        # If available, it must not empty
        if not content:
            logger.error(LogFormatter.format(
                77, "'Solved by' field has length 0", req.get_id()))
            return False

        # Step through the list
        dep_list = content.split()
        tracer.debug("dependent list [%s]", dep_list)
        for dep in dep_list:
            if dep not in self.__requirements:
                logger.error(LogFormatter.format(
                    74, "'Solved by' points to a "
                    "non-existing requirement '%s'" % dep, req.get_id()))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if dep == req.get_id():
                logger.error(LogFormatter.format(
                    75, "'Solved by' points to the "
                    "requirement itself", req.get_id()))
                return False

            # Mark down the depends on...
            dep_req = self.__requirements[dep]
            # This is exactly the other way as used in the 'Depends on'
            tracer.debug("Add edge [%s] -> [%s]",
                         dep_req.get_id(), req.get_id())
            Digraph.create_edge(req, dep_req)

        # Delete the original tag
        del req.brmo["Solved by"]
        return True
コード例 #20
0
ファイル: RequirementSet.py プロジェクト: samjaninf/rmtoo
    def __resolve_solved_by_one_req(self, req_node):
        '''Resolve the 'Solved by' for one requirement.'''
        assert isinstance(req_node, RequirementDNode)
        req = req_node.get_requirement()
        tracer.debug("Called: requirement id [%s]." % req.get_id())

        # It is a 'normal' case when there is no 'Solved by' (until now).
        if "Solved by" not in req.brmo:
            return True

        content = req.brmo["Solved by"].get_content()
        # If available, it must not empty
        if len(content) == 0:
            logger.error(
                LogFormatter.format(77, "'Solved by' field has length 0",
                                    req.get_id()))
            return False

        # Step through the list
        dep_list = content.split()
        tracer.debug("dependent list [%s]" % dep_list)
        for dep in dep_list:
            if dep not in self._named_nodes:
                logger.error(
                    LogFormatter.format(
                        74, "'Solved by' points to a "
                        "non-existing requirement '%s'" % dep, req.get_id()))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if dep == req.get_id():
                logger.error(
                    LogFormatter.format(
                        75, "'Solved by' points to the "
                        "requirement itself", req.id))
                return False

            # Mark down the depends on...
            dep_req_node = self._named_nodes[dep]
            assert isinstance(dep_req_node, RequirementDNode)

            # This is exactly the other way as used in the 'Depends on'
            tracer.debug(
                "Add edge [%s] -> [%s]" %
                (dep_req_node.get_requirement().get_id(), req.get_id()))
            Digraph.create_edge(self, req_node, dep_req_node)

        # Delete the original tag
        del req.brmo["Solved by"]
        return True
コード例 #21
0
ファイル: RequirementSet.py プロジェクト: CrypticGator/rmtoo
    def __resolve_solved_by_one_req(self, req_node):
        '''Resolve the 'Solved by' for one requirement.'''
        assert isinstance(req_node, RequirementDNode)
        req = req_node.get_requirement()
        tracer.debug("Called: requirement id [%s]." % req.get_id())

        # It is a 'normal' case when there is no 'Solved by' (until now).
        if "Solved by" not in req.brmo:
            return True

        content = req.brmo["Solved by"].get_content()
        # If available, it must not empty
        if len(content) == 0:
            logger.error(LogFormatter.format(
                        77, "'Solved by' field has length 0", req.get_id()))
            return False

        # Step through the list
        dep_list = content.split()
        tracer.debug("dependent list [%s]" % dep_list)
        for dep in dep_list:
            if dep not in self._named_nodes:
                logger.error(LogFormatter.format(
                        74, "'Solved by' points to a "
                        "non-existing requirement '%s'" % dep, req.get_id()))
                return False
            # It is not allowed to have self-references: it does not
            # make any sense, that a requirement references itself.
            if dep == req.get_id():
                logger.error(LogFormatter.format(
                           75, "'Solved by' points to the "
                           "requirement itself", req.id))
                return False

            # Mark down the depends on...
            dep_req_node = self._named_nodes[dep]
            assert isinstance(dep_req_node, RequirementDNode)

            # This is exactly the other way as used in the 'Depends on'
            tracer.debug("Add edge [%s] -> [%s]" %
                         (dep_req_node.get_requirement().get_id(),
                          req.get_id()))
            Digraph.create_edge(self, req_node, dep_req_node)

        # Delete the original tag
        del req.brmo["Solved by"]
        return True