コード例 #1
0
 def _validate_roots(self):
     self.roots = [
         root
         for root in self.roots
         if not hasattr(root, "parentNode") or root.parentNode is None or is_root(root.key)
     ]
     self._set_warning_icons()
コード例 #2
0
ファイル: db_tree.py プロジェクト: vitaly-efremov/QuantumTest
    def add_node(self, xpath):
        """
            Method adds a new node which is specified by xpath.
            It can be used as validation one for creating element only if exists.
        """
        if self.get_node(xpath) is not None:
            logger.info("'{}' is already exists, no need to add it.".format(xpath))
            return

        parent_xpath = get_parent_xpath(xpath)
        parent_node = self.get_node(parent_xpath)

        if parent_node is None:
            if is_root(xpath):
                logger.debug("'{}' is the root so adding into the root list.".format(xpath))
                root = create_element(get_tag_name(xpath))
                root.key = xpath
                self.add_new_root(root)
                return root
            else:
                # If the parent haven't created yet.
                logger.error("There is no node for specified xpath: '{}'. Creating it.".format(parent_xpath))
                parent_node = self.add_node(parent_xpath)
                logger.info("Node for specified xpath: '{}' was created it.".format(parent_xpath))

        if parent_node is not None:
            element = create_element(get_tag_name(xpath))
            element.key = xpath
            element.parentNode = parent_node
            parent_node.append(element)

            self.add_new_node(element)
            return element
        else:
            print("s")
        return