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