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


Python Index.read_uri方法代码示例

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


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

示例1: update_repo

# 需要导入模块: from pisi.index import Index [as 别名]
# 或者: from pisi.index.Index import read_uri [as 别名]
def update_repo(repo):
    ctx.ui.info(_('* Updating repository: %s') % repo)
    index = Index()
    if ctx.repodb.has_repo(repo):
        index.read_uri(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
    else:
        raise Error(_('No repository named %s found.') % repo)
    index.update_db(repo)
    ctx.ui.info(_('\n* Package database updated.'))
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:11,代码来源:api.py

示例2: rebuild_repo

# 需要导入模块: from pisi.index import Index [as 别名]
# 或者: from pisi.index.Index import read_uri [as 别名]
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo)
    
    if ctx.repodb.has_repo(repo):
        repouri = URI(ctx.repodb.get_repo(repo).indexuri.get_uri())
        indexname = repouri.filename()
        index = Index()
        indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname)
        tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
        pisi.util.clean_dir(tmpdir)
        pisi.util.check_dir(tmpdir)
        try:
            index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there
        except IOError, e:
            ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e)))
            return
        ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:19,代码来源:api.py

示例3: update_repo

# 需要导入模块: from pisi.index import Index [as 别名]
# 或者: from pisi.index.Index import read_uri [as 别名]
def update_repo(repo, force=False):
    ctx.ui.info(_('* Updating repository: %s') % repo)
    index = Index()
    if ctx.repodb.has_repo(repo):
        repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        try:
            index.read_uri(repouri, repo)
        except pisi.file.AlreadyHaveException, e:
            ctx.ui.info(_('No updates available for repository %s.') % repo)
            if force:
                ctx.ui.info(_('Updating database at any rate as requested'))
                index.read_uri(repouri, repo, force = force)
            else:
                return
        try:
            index.check_signature(repouri, repo)
        except pisi.file.NoSignatureFound, e:
            ctx.ui.warning(e)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:20,代码来源:api.py

示例4: rebuild_repo

# 需要导入模块: from pisi.index import Index [as 别名]
# 或者: from pisi.index.Index import read_uri [as 别名]
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo, noln=True)
    
    index = Index()
    if ctx.repodb.has_repo(repo):
        repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        indexname = os.path.basename(repouri)
        indexpath = pisi.util.join_path(ctx.config.lib_dir(), 'index', repo, indexname)

        if os.path.exists(indexpath):
            repouri = indexpath

        try:
            index.read_uri(repouri, repo, force = True)
        except IOError:
            ctx.ui.warning(_("Repo index file \'%s\' not found.") % repouri)
            return
    else:
        raise Error(_('No repository named %s found.') % repo)

    ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
    ctx.ui.info(_('OK.'))
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:24,代码来源:api.py

示例5: __init__

# 需要导入模块: from pisi.index import Index [as 别名]
# 或者: from pisi.index.Index import read_uri [as 别名]
class PisiCrawler:
    """ Lists and downloads pisi packages in a given repository """

    def __init__(self):
        """Constructor"""

    # -------------------------------------------------------------------
    def readRepo(self, repo_url, dest_dir="./"):
        """Reads repo and fetches index files"""
        ### Imports ###
        from pisi.index import Index
        from os import mkdir

        ### Check if address got a trailing slash ###
        if repo_url.split("/")[-1]:  # If not, add a trailing slash.
            self.repo_url = repo_url + "/"
        else:  #  Else, use it.
            self.repo_url = repo_url

        ### Check dest_dir ###
        if dest_dir.split("/")[-1]:
            dest_dir = dest_dir + "/"

        self.dest_dir = dest_dir + self.repo_url.split("/")[-2]
        self.index_url = self.repo_url + "pisi-index.xml.bz2"

        ### Create Pisi-Index instance ###
        self.pi = Index()
        try:
            self.pi.read_uri(self.index_url, self.dest_dir)
        except:
            pass
        self.pi.read((self.dest_dir + "/pisi-index.xml"))

    # -------------------------------------------------------------------
    def listPackages(self, fullURI=True):
        """Lists packages for given repo address.
        
        listPackages(fullURI=True)
            
        Set fullURI to False to get just package names.
        """
        ### Iterate over packages ###
        i = 1
        for p in self.pi.packages:
            if fullURI:
                print i, "--", self.repo_url + p.packageURI
            else:
                print i, "--", p.packageURI
            i += 1

    # -------------------------------------------------------------------
    def getPackageList(self):
        """Returns a list of package uri's"""
        liste = []
        for p in self.pi.packages:
            p_uri = self.repo_url + p.packageURI
            liste.append(p_uri)
        return liste

    # ----------------------------------------------------------------------
    def fetchPackages(self, destination=None):
        """Downloads packages to destination directory """
        from urlgrabber.grabber import URLGrabber
        from urlgrabber.progress import TextMeter
        from os import path, chdir

        if destination:
            chdir(destination)
        else:
            chdir(self.dest_dir)

        ### URLGrabber objects ###
        t = TextMeter()
        g = URLGrabber(progress_obj=t)

        ### Start Iteration over list of packages' URIs ###
        for uri in self.getPackageList():
            pisifile = uri.split("/")[-1]
            if path.exists(pisifile):
                print pisifile, "--- No Update! Skipping..."
                continue
            try:
                g.urlgrab(uri)
            except:
                print "Error while downloading file %s" % pisifile
                break
        print "Finished."

    # ----------------------------------------------------------------------
    def generatePackageContents(to="cpickle"):
        """Generates lspisi outputs of pisi packages.
        Filetypes; cpickle, pickle, text"""
        pass
开发者ID:havan,项目名称:porsuk,代码行数:96,代码来源:pisi_crawler.py


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