Exemple #1
0
 def parse(self, xml_elem):
     self.src = qixml.parse_required_attr(xml_elem, "src")
     self.manifest = qixml.parse_bool_attr(xml_elem, "manifest")
     self.review = qixml.parse_bool_attr(xml_elem, "review")
     self.profile = xml_elem.get("profile", "default")
     self.remote = xml_elem.get("remote", "origin")
     self.branch = xml_elem.get("branch", "master")
Exemple #2
0
 def parse(self, xml_element):
     self.name = qixml.parse_required_attr(xml_element, "name")
     xml_path = xml_element.get("path")
     if not xml_path:
         self.path = self.name.replace(".git", "")
     else:
         self.path = qisys.sh.to_posix_path(xml_path)
         self.path = posixpath.normpath(xml_path)
     self.revision = xml_element.get("revision")
     self.worktree_name = xml_element.get("worktree_name")
     self.review = qixml.parse_bool_attr(xml_element, "review")
     self.remote = xml_element.get("remote", default="origin")
Exemple #3
0
def test_qixml_parse_bool_attr():
    tree = etree.fromstring("<foo />")
    assert qixml.parse_bool_attr(tree, "bar", default=True) == True
    assert qixml.parse_bool_attr(tree, "bar", default=False) == False
    assert qixml.parse_bool_attr(tree, "bar") == False

    tree = etree.fromstring("<foo bar=\"true\" />")
    assert qixml.parse_bool_attr(tree, "bar", default=True) == True
    assert qixml.parse_bool_attr(tree, "bar", default=False) == True
    assert qixml.parse_bool_attr(tree, "bar") == True

    tree = etree.fromstring("<foo bar=\"false\" />")
    assert qixml.parse_bool_attr(tree, "bar", default=True) == False
    assert qixml.parse_bool_attr(tree, "bar", default=False) == False
    assert qixml.parse_bool_attr(tree, "bar") == False

    tree = etree.fromstring("<foo bar=\"1\" />")
    assert qixml.parse_bool_attr(tree, "bar", default=True) == True
    assert qixml.parse_bool_attr(tree, "bar", default=False) == True
    assert qixml.parse_bool_attr(tree, "bar") == True

    tree = etree.fromstring("<foo bar=\"0\" />")
    assert qixml.parse_bool_attr(tree, "bar", default=True) == False
    assert qixml.parse_bool_attr(tree, "bar", default=False) == False
    assert qixml.parse_bool_attr(tree, "bar") == False

    tree = etree.fromstring("<foo bar=\"blaaaah\" />")

    with pytest.raises(Exception):
        qixml.parse_bool_attr(tree, "bar")
Exemple #4
0
 def parse(self, tree):
     self.incredibuild = qixml.parse_bool_attr(tree, "incredibuild")