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


Python Repository.write_archive方法代码示例

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


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

示例1: install_package

# 需要导入模块: from pygit2 import Repository [as 别名]
# 或者: from pygit2.Repository import write_archive [as 别名]
    def install_package(self, pkg_name, expression):
        package_cache_path = path.join(APP_CACHE_DIR, pkg_name)

        # Check if the package is cached
        try:
            repo = Repository(package_cache_path)

            # TODO: check lastest version
            # If lastest is cached, advance
            # If no, prompt user
        except KeyError as e:
            repo = clone_repository(APP_REMOTE['url'], package_cache_path)

        # Get suitable version for the expression
        versions = utils.get_versions_cached(repo)
        version = max_satisfy(versions=versions.keys(), expression='')

        package_archive_name = '{0}-{1}.tar'.format(pkg_name, version)
        package_archive_path = path.join(APP_ARCHIVE_DIR, package_archive_name)

        # Create archive file
        # If the file already exists, move forward
        if path.isfile(package_archive_path):
            with tarfile.open(package_archive_path, 'w') as archive:
                repo.write_archive(archive=archive, treeish=versions[version].tree_id)

        # TODO: use strategy
        # Extract archive to package dir
        path_to_package = path.join(USER_PACKAGE_FOLDER, 'user', pkg_name)
        tar = tarfile.open(package_archive_path)
        tar.extractall(path=path_to_package)
        tar.close()
开发者ID:nghiattran,项目名称:pm,代码行数:34,代码来源:default.py


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