當前位置: 首頁>>代碼示例>>Python>>正文


Python parser.bar方法代碼示例

本文整理匯總了Python中html.parser.bar方法的典型用法代碼示例。如果您正苦於以下問題:Python parser.bar方法的具體用法?Python parser.bar怎麽用?Python parser.bar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在html.parser的用法示例。


在下文中一共展示了parser.bar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_remove_multiple_items

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_remove_multiple_items(self):
        b = """isinstance(x, (int, int, int))"""
        a = """isinstance(x, int)"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float))"""
        a = """isinstance(x, (int, float))"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float, str))"""
        a = """isinstance(x, (int, float, str))"""
        self.check(b, a)

        b = """isinstance(foo() + bar(), (x(), y(), x(), int, int))"""
        a = """isinstance(foo() + bar(), (x(), y(), x(), int))"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:18,代碼來源:test_fixers.py

示例2: test_import_as

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_import_as(self):
        b = "from itertools import izip, bar as bang, imap"
        a = "from itertools import bar as bang"
        self.check(b, a)

        b = "from itertools import izip as _zip, imap, bar"
        a = "from itertools import bar"
        self.check(b, a)

        b = "from itertools import imap as _map"
        a = ""
        self.check(b, a)

        b = "from itertools import imap as _map, izip as _zip"
        a = ""
        self.check(b, a)

        s = "from itertools import bar as bang"
        self.unchanged(s) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:21,代碼來源:test_fixers.py

示例3: test_import

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_import(self):
        b = "import foo"
        a = "from . import foo"
        self.check_both(b, a)

        b = "import foo, bar"
        a = "from . import foo, bar"
        self.check_both(b, a)

        b = "import foo, bar, x"
        a = "from . import foo, bar, x"
        self.check_both(b, a)

        b = "import x, y, z"
        a = "from . import x, y, z"
        self.check_both(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:18,代碼來源:test_fixers.py

示例4: test_weird_comments

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_weird_comments(self):
        b = """apply(   # foo
          f, # bar
          args)"""
        a = """f(*args)"""
        self.check(b, a)

    # These should *not* be touched 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:10,代碼來源:test_fixers.py

示例5: test_prefix_preservation

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_prefix_preservation(self):
        b = """if    isinstance(  foo(), (  bar, bar, baz )) : pass"""
        a = """if    isinstance(  foo(), (  bar, baz )) : pass"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:6,代碼來源:test_fixers.py

示例6: test_import_module

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_import_module(self):
        for old, new in self.modules.items():
            b = "import %s" % old
            a = "import %s" % new
            self.check(b, a)

            b = "import foo, %s, bar" % old
            a = "import foo, %s, bar" % new
            self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:test_fixers.py

示例7: test_import_from

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_import_from(self):
        for old, new in self.modules.items():
            b = "from %s import foo" % old
            a = "from %s import foo" % new
            self.check(b, a)

            b = "from %s import foo, bar" % old
            a = "from %s import foo, bar" % new
            self.check(b, a)

            b = "from %s import (yes, no)" % old
            a = "from %s import (yes, no)" % new
            self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:15,代碼來源:test_fixers.py

示例8: test_multiple_imports_as

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_multiple_imports_as(self):
        b = """
            import copy_reg as bar, HTMLParser as foo, urlparse
            s = urlparse.spam(bar.foo())
            """
        a = """
            import copyreg as bar, html.parser as foo, urllib.parse
            s = urllib.parse.spam(bar.foo())
            """
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:12,代碼來源:test_fixers.py

示例9: test_shadowing_import_1

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_shadowing_import_1(self):
        s = """
            import foo.bar as next

            class A:
                def next(self, a, b):
                    pass
            """
        self.warns_unchanged(s, "Calls to builtin next() possibly shadowed") 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:test_fixers.py

示例10: test_shadowing_import_2

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_shadowing_import_2(self):
        s = """
            import bar, bar.foo as next

            class A:
                def next(self, a, b):
                    pass
            """
        self.warns_unchanged(s, "Calls to builtin next() possibly shadowed") 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:test_fixers.py

示例11: test_shadowing_import_3

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_shadowing_import_3(self):
        s = """
            import bar, bar.foo as next, baz

            class A:
                def next(self, a, b):
                    pass
            """
        self.warns_unchanged(s, "Calls to builtin next() possibly shadowed") 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:test_fixers.py

示例12: test_ifilter_and_zip_longest

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_ifilter_and_zip_longest(self):
        for name in "filterfalse", "zip_longest":
            b = "from itertools import i%s" % (name,)
            a = "from itertools import %s" % (name,)
            self.check(b, a)

            b = "from itertools import imap, i%s, foo" % (name,)
            a = "from itertools import %s, foo" % (name,)
            self.check(b, a)

            b = "from itertools import bar, i%s, foo" % (name,)
            a = "from itertools import bar, %s, foo" % (name,)
            self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:15,代碼來源:test_fixers.py

示例13: test_not_in_package

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_not_in_package(self):
        s = "import bar"
        self.always_exists = False
        self.present_files = set(["bar.py"])
        self.unchanged(s) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:7,代碼來源:test_fixers.py

示例14: test_with_absolute_import_enabled

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_with_absolute_import_enabled(self):
        s = "from __future__ import absolute_import\nimport bar"
        self.always_exists = False
        self.present_files = set(["__init__.py", "bar.py"])
        self.unchanged(s) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:7,代碼來源:test_fixers.py

示例15: test_in_package

# 需要導入模塊: from html import parser [as 別名]
# 或者: from html.parser import bar [as 別名]
def test_in_package(self):
        b = "import bar"
        a = "from . import bar"
        self.always_exists = False
        self.present_files = set(["__init__.py", "bar.py"])
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:test_fixers.py


注:本文中的html.parser.bar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。