当前位置: 首页>>代码示例>>Python>>正文


Python XPathQuery.matches方法代码示例

本文整理汇总了Python中twisted.words.xish.xpath.XPathQuery.matches方法的典型用法代码示例。如果您正苦于以下问题:Python XPathQuery.matches方法的具体用法?Python XPathQuery.matches怎么用?Python XPathQuery.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.words.xish.xpath.XPathQuery的用法示例。


在下文中一共展示了XPathQuery.matches方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_locationAllChilds

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_locationAllChilds(self):
     """
     Test finding childs of foo.
     """
     xp = XPathQuery("/foo/*")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1, self.bar2, self.bar4, self.bar5, self.bar6, self.bar7])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:9,代码来源:test_xpath.py

示例2: test_textConditionUnicode

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_textConditionUnicode(self):
     """
     A node can be matched by text with non-ascii code points.
     """
     xp = XPathQuery(u"//*[text()='\N{SNOWMAN}']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.quux])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:9,代码来源:test_xpath.py

示例3: test_attributeWithValueAny

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_attributeWithValueAny(self):
     """
     Test find nodes with attribute having value.
     """
     xp = XPathQuery("/foo/*[@attrib2='value2']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar2])
开发者ID:0004c,项目名称:VTK,代码行数:9,代码来源:test_xpath.py

示例4: test_orOperator

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_orOperator(self):
     """
     Test boolean or operator in condition.
     """
     xp = XPathQuery("//bar[@attrib5='value4' or @attrib5='value5']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar5, self.bar6])
开发者ID:0004c,项目名称:VTK,代码行数:9,代码来源:test_xpath.py

示例5: test_position

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_position(self):
     """
     Test finding element at position.
     """
     xp = XPathQuery("/foo/bar[2]")
     self.assertEqual(xp.matches(self.e), 1)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar1])
开发者ID:0004c,项目名称:VTK,代码行数:9,代码来源:test_xpath.py

示例6: test_locationFooBarFoo

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_locationFooBarFoo(self):
     """
     Test finding foos at the second level.
     """
     xp = XPathQuery("/foo/bar/foo")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e), [self.subfoo, self.subfoo3, self.subfoo4])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:9,代码来源:test_xpath.py

示例7: test_andOperator

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_andOperator(self):
     """
     Test boolean and operator in condition.
     """
     xp = XPathQuery("//bar[@attrib4='value4' and @attrib5='value5']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar5])
开发者ID:0004c,项目名称:VTK,代码行数:9,代码来源:test_xpath.py

示例8: test_locationWithValueUnicode

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_locationWithValueUnicode(self):
     """
     Nodes' attributes can be matched with non-ASCII values.
     """
     xp = XPathQuery(u"/foo/*[@attrib6='á']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar7])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:9,代码来源:test_xpath.py

示例9: test_booleanOperatorsParens

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_booleanOperatorsParens(self):
     """
     Test multiple boolean operators in condition with parens.
     """
     xp = XPathQuery("""//bar[@attrib4='value4' and
                              (@attrib5='value4' or @attrib5='value6')]""")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar6, self.bar7])
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:test_xpath.py

示例10: test_anyLocationAndText

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_anyLocationAndText(self):
     """
     Test finding any nodes named gar and getting their text contents.
     """
     xp = XPathQuery("//gar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.gar1, self.gar2, self.gar3, self.gar4])
     self.assertEquals(xp.queryForStringList(self.e), ["DEF", "ABC", "JKL", "MNO"])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:10,代码来源:test_xpath.py

示例11: test_anyLocation

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_anyLocation(self):
     """
     Test finding any nodes named bar.
     """
     xp = XPathQuery("//bar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(
         xp.queryForNodes(self.e), [self.bar1, self.bar2, self.bar3, self.bar4, self.bar5, self.bar6, self.bar7]
     )
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:11,代码来源:test_xpath.py

示例12: test_textNotOperator

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_textNotOperator(self):
     """
     Test for not operator.
     """
     xp = XPathQuery("/foo[not(@nosuchattrib)]")
     self.assertEqual(xp.matches(self.e), True)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py

示例13: test_textCondition

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_textCondition(self):
     """
     Test matching a node with given text.
     """
     xp = XPathQuery("/foo[text() = 'somecontent']")
     self.assertEqual(xp.matches(self.e), True)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py

示例14: test_attributeWithValue

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_attributeWithValue(self):
     """
     Test matching node with attribute having value.
     """
     xp = XPathQuery("/foo[@attrib1='value1']")
     self.assertEqual(xp.matches(self.e), 1)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py

示例15: test_namespaceNotFound

# 需要导入模块: from twisted.words.xish.xpath import XPathQuery [as 别名]
# 或者: from twisted.words.xish.xpath.XPathQuery import matches [as 别名]
 def test_namespaceNotFound(self):
     """
     Test not matching node with wrong namespace.
     """
     xp = XPathQuery("/foo[@xmlns='badns']/bar2")
     self.assertEqual(xp.matches(self.e), 0)
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py


注:本文中的twisted.words.xish.xpath.XPathQuery.matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。