當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。