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


Python Parser.selector方法代码示例

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


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

示例1: test_unnested_combine_ancestor_selector

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_unnested_combine_ancestor_selector(self):
     src = u'a &'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     with self.assertRaises(errors.CSSSyntaxError) as cm:
         parser.selector()
     self.assertEqual("The '&' selector is only allowed within nested ruleset scopes.", 
                      cm.exception.msg)
开发者ID:colossalbit,项目名称:cssypy,代码行数:10,代码来源:test_parsers.py

示例2: test_class_selector

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_class_selector(self):
     src = u'.myclass'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=None,
                     tail=[ClassSelector(name=u'myclass')]
                 ),
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:17,代码来源:test_parsers.py

示例3: test_type_selector

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_type_selector(self):
     src = u'div'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'div'),
                     tail=[]
                 ),
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:17,代码来源:test_parsers.py

示例4: test_negation_selector

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_negation_selector(self):
     src = u'a:not( #myid )'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'a'),
                     tail=[
                         NegationSelector(
                             arg=IdSelector(name=u'myid')
                         ),
                     ]
                 )
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:21,代码来源:test_parsers.py

示例5: test_pseudo_element_selector2

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_pseudo_element_selector2(self):
     src = u'a::foo'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'a'),
                     tail=[
                         PseudoElementSelector(
                             node=Ident(name=u'foo')
                         ),
                     ]
                 )
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:21,代码来源:test_parsers.py

示例6: test_child_combinator

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_child_combinator(self):
     src = u'a > b'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'a'),
                     tail=[]
                 ),
                 ChildCombinator(),
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'b'),
                     tail=[]
                 ),
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:22,代码来源:test_parsers.py

示例7: test_whitespace_combinator2

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_whitespace_combinator2(self):
     src = u'a.myclass b#myid'
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     sel = parser.selector()
     expected = \
         Selector(
             children=[
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'a'),
                     tail=[ClassSelector(name=u'myclass')]
                 ),
                 DescendantCombinator(),
                 SimpleSelectorSequence(
                     head=TypeSelector(name=u'b'),
                     tail=[IdSelector(name=u'myid')]
                 ),
             ]
         )
     self.assertEqual(dump(expected), dump(sel))
开发者ID:colossalbit,项目名称:cssypy,代码行数:22,代码来源:test_parsers.py

示例8: test_bad_class_selector

# 需要导入模块: from cssypy.parsers import Parser [as 别名]
# 或者: from cssypy.parsers.Parser import selector [as 别名]
 def test_bad_class_selector(self):
     src = u'."this is a string"   '
     parser = Parser(src)
     self.assertTrue(parser.match(tokens.START))
     with self.assertRaises(errors.CSSSyntaxError):
         parser.selector()
开发者ID:colossalbit,项目名称:cssypy,代码行数:8,代码来源:test_parsers.py


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