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


Python zipp.Path方法代码示例

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


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

示例1: load

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def load(root):
    """
    Given a source directory (root) of a package,
    return an importlib.metadata.Distribution object
    with metadata build from that package.
    """
    root = os.path.expanduser(root)
    system = compat_system(root)
    builder = functools.partial(build, source_dir=root, system=system)
    path = Path(build_as_zip(builder))
    return imp_meta.PathDistribution(path) 
开发者ID:pypa,项目名称:pep517,代码行数:13,代码来源:meta.py

示例2: _switch_path

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def _switch_path(path):
        if not PYPY_OPEN_BUG or os.path.isfile(path):  # pragma: no branch
            with suppress(Exception):
                return zipp.Path(path)
        return pathlib.Path(path) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:7,代码来源:__init__.py

示例3: temp_dir

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def temp_dir():
    tmpdir = tempfile.mkdtemp()
    try:
        yield pathlib.Path(tmpdir)
    finally:
        shutil.rmtree(tmpdir) 
开发者ID:jaraco,项目名称:zipp,代码行数:8,代码来源:test_zipp.py

示例4: zipfile_ondisk

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def zipfile_ondisk(self):
        tmpdir = pathlib.Path(self.fixtures.enter_context(temp_dir()))
        for alpharep in self.zipfile_alpharep():
            buffer = alpharep.fp
            alpharep.close()
            path = tmpdir / alpharep.filename
            with path.open("wb") as strm:
                strm.write(buffer.getvalue())
            yield path 
开发者ID:jaraco,项目名称:zipp,代码行数:11,代码来源:test_zipp.py

示例5: test_iterdir_and_types

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_iterdir_and_types(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            assert root.is_dir()
            a, b, g = root.iterdir()
            assert a.is_file()
            assert b.is_dir()
            assert g.is_dir()
            c, f, d = b.iterdir()
            assert c.is_file() and f.is_file()
            e, = d.iterdir()
            assert e.is_file()
            h, = g.iterdir()
            i, = h.iterdir()
            assert i.is_file() 
开发者ID:jaraco,项目名称:zipp,代码行数:17,代码来源:test_zipp.py

示例6: test_subdir_is_dir

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_subdir_is_dir(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            assert (root / 'b').is_dir()
            assert (root / 'b/').is_dir()
            assert (root / 'g').is_dir()
            assert (root / 'g/').is_dir() 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例7: test_open

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_open(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            a, b, g = root.iterdir()
            with a.open() as strm:
                data = strm.read()
            assert data == "content of a" 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例8: test_open_extant_directory

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_open_extant_directory(self):
        """
        Attempting to open a directory raises IsADirectoryError.
        """
        zf = zipp.Path(add_dirs(build_alpharep_fixture()))
        with self.assertRaises(IsADirectoryError):
            zf.joinpath('b').open() 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例9: test_open_missing_directory

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_open_missing_directory(self):
        """
        Attempting to open a missing directory raises FileNotFoundError.
        """
        zf = zipp.Path(add_dirs(build_alpharep_fixture()))
        with self.assertRaises(FileNotFoundError):
            zf.joinpath('z').open() 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例10: test_read

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_read(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            a, b, g = root.iterdir()
            assert a.read_text() == "content of a"
            assert a.read_bytes() == b"content of a" 
开发者ID:jaraco,项目名称:zipp,代码行数:8,代码来源:test_zipp.py

示例11: test_joinpath

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_joinpath(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            a = root.joinpath("a")
            assert a.is_file()
            e = root.joinpath("b").joinpath("d").joinpath("e.txt")
            assert e.read_text() == "content of e" 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例12: test_traverse_truediv

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_traverse_truediv(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            a = root / "a"
            assert a.is_file()
            e = root / "b" / "d" / "e.txt"
            assert e.read_text() == "content of e" 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例13: test_pathlike_construction

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_pathlike_construction(self):
        """
        zipp.Path should be constructable from a path-like object
        """
        for zipfile_ondisk in self.zipfile_ondisk():
            pathlike = pathlib.Path(str(zipfile_ondisk))
            zipp.Path(pathlike) 
开发者ID:jaraco,项目名称:zipp,代码行数:9,代码来源:test_zipp.py

示例14: test_traverse_pathlike

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_traverse_pathlike(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            root / pathlib.Path("a") 
开发者ID:jaraco,项目名称:zipp,代码行数:6,代码来源:test_zipp.py

示例15: test_parent

# 需要导入模块: import zipp [as 别名]
# 或者: from zipp import Path [as 别名]
def test_parent(self):
        for alpharep in self.zipfile_alpharep():
            root = zipp.Path(alpharep)
            assert (root / 'a').parent.at == ''
            assert (root / 'a' / 'b').parent.at == 'a/' 
开发者ID:jaraco,项目名称:zipp,代码行数:7,代码来源:test_zipp.py


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