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


Python pkg_resources.split_sections方法代碼示例

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


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

示例1: testSplitting

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def testSplitting(self):
        sample = """
                    x
                    [Y]
                    z

                    a
                    [b ]
                    # foo
                    c
                    [ d]
                    [q]
                    v
                    """
        self.assertEqual(list(pkg_resources.split_sections(sample)),
            [(None,["x"]), ("Y",["z","a"]), ("b",["c"]), ("d",[]), ("q",["v"])]
        )
        self.assertRaises(ValueError,list,pkg_resources.split_sections("[foo")) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:20,代碼來源:test_resources.py

示例2: pkginfo_to_metadata

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 1.3 aka
    old-draft Metadata 2.0 format.
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.0')
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        with open(requires_path) as requires_file:
            requires = requires_file.read()
        for extra, reqs in sorted(pkg_resources.split_sections(requires),
                                  key=lambda x: x[0] or ''):
            for item in generate_requirements({extra: reqs}):
                pkg_info[item[0]] = item[1]

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:metadata.py

示例3: pkginfo_to_metadata

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.1')
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        with open(requires_path) as requires_file:
            requires = requires_file.read()
        for extra, reqs in sorted(pkg_resources.split_sections(requires),
                                  key=lambda x: x[0] or ''):
            for item in generate_requirements({extra: reqs}):
                pkg_info[item[0]] = item[1]

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:23,代碼來源:metadata.py

示例4: pkginfo_to_metadata

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 1.3 aka
    old-draft Metadata 2.0 format.
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.0')
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        requires = open(requires_path).read()
        for extra, reqs in sorted(pkg_resources.split_sections(requires),
                                  key=lambda x: x[0] or ''):
            condition = ''
            if extra and ':' in extra: # setuptools extra:condition syntax
                extra, condition = extra.split(':', 1)
            if extra:
                pkg_info['Provides-Extra'] = extra
                if condition:
                    condition += " and "
                condition += 'extra == %s' % repr(extra)
            if condition:
                condition = '; ' + condition
            for new_req in sorted(convert_requirements(reqs)):
                pkg_info['Requires-Dist'] = new_req + condition

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info 
開發者ID:jpush,項目名稱:jbox,代碼行數:33,代碼來源:metadata.py

示例5: testSplitting

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def testSplitting(self):
        sample = """
                    x
                    [Y]
                    z

                    a
                    [b ]
                    # foo
                    c
                    [ d]
                    [q]
                    v
                    """
        assert (
            list(pkg_resources.split_sections(sample))
            ==
            [
                (None, ["x"]),
                ("Y", ["z", "a"]),
                ("b", ["c"]),
                ("d", []),
                ("q", ["v"]),
            ]
        )
        with pytest.raises(ValueError):
            list(pkg_resources.split_sections("[foo")) 
開發者ID:pypa,項目名稱:pkg_resources,代碼行數:29,代碼來源:test_resources.py

示例6: pkginfo_to_metadata

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.1')
    # Those will be regenerated from `requires.txt`.
    del pkg_info['Provides-Extra']
    del pkg_info['Requires-Dist']
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        with open(requires_path) as requires_file:
            requires = requires_file.read()

        parsed_requirements = sorted(pkg_resources.split_sections(requires),
                                     key=lambda x: x[0] or '')
        for extra, reqs in parsed_requirements:
            for key, value in generate_requirements({extra: reqs}):
                if (key, value) not in pkg_info.items():
                    pkg_info[key] = value

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:29,代碼來源:metadata.py

示例7: pkginfo_to_metadata

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def pkginfo_to_metadata(egg_info_path, pkginfo_path):
    """
    Convert .egg-info directory with PKG-INFO to the Metadata 1.3 aka
    old-draft Metadata 2.0 format.
    """
    pkg_info = read_pkg_info(pkginfo_path)
    pkg_info.replace_header('Metadata-Version', '2.0')
    requires_path = os.path.join(egg_info_path, 'requires.txt')
    if os.path.exists(requires_path):
        requires = open(requires_path).read()
        for extra, reqs in pkg_resources.split_sections(requires):
            condition = ''
            if extra and ':' in extra: # setuptools extra:condition syntax
                extra, condition = extra.split(':', 1)
            if extra:
                pkg_info['Provides-Extra'] = extra
                if condition:
                    condition += " and "
                condition += 'extra == %s' % repr(extra)
            if condition:
                condition = '; ' + condition
            for new_req in convert_requirements(reqs):
                pkg_info['Requires-Dist'] = new_req + condition

    description = pkg_info['Description']
    if description:
        pkg_info.set_payload(dedent_description(pkg_info))
        del pkg_info['Description']

    return pkg_info 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:32,代碼來源:metadata.py

示例8: testSplitting

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import split_sections [as 別名]
def testSplitting(self):
        sample = """
                    x
                    [Y]
                    z

                    a
                    [b ]
                    # foo
                    c
                    [ d]
                    [q]
                    v
                    """
        assert (
            list(pkg_resources.split_sections(sample))
                ==
            [
                (None, ["x"]),
                ("Y", ["z", "a"]),
                ("b", ["c"]),
                ("d", []),
                ("q", ["v"]),
            ]
        )
        with pytest.raises(ValueError):
            list(pkg_resources.split_sections("[foo")) 
開發者ID:francelabs,項目名稱:datafari,代碼行數:29,代碼來源:test_resources.py


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