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


Python file.File类代码示例

本文整理汇总了Python中pisi.file.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_repo_doc

    def get_repo_doc(self, repo_name):
        if not self.has_repo(repo_name):
            raise RepoError(_("Repository %s does not exist.") % repo)

        repo = self.get_repo(repo_name)

        index_path = repo.indexuri.get_uri()

        #FIXME Local index files should also be cached.
        if File.is_compressed(index_path) or repo.indexuri.is_remote_file():
            index = os.path.basename(index_path)
            index_path = pisi.util.join_path(ctx.config.index_dir(),
                                             repo_name, index)

            if File.is_compressed(index_path):
                index_path = os.path.splitext(index_path)[0]

        if not os.path.exists(index_path):
            ctx.ui.warning(_("%s repository needs to be updated") % repo_name)
            return piksemel.newDocument("PISI")

        try:
            return piksemel.parse(index_path)
        except Exception, e:
            raise RepoError(_("Error parsing repository index information. Index file does not exist or is malformed."))
开发者ID:Pardus-Linux,项目名称:pisi,代码行数:25,代码来源:repodb.py

示例2: readxml

 def readxml(self, uri, tmpDir='/tmp', sha1sum=False, compress=None, sign=None):
     uri = File.make_uri(uri)
     localpath = File.download(uri, tmpDir,sha1sum=sha1sum,compress=compress,sign=sign)
     try:
         self.doc = iks.parse(localpath)
         return self.doc
     except Exception, e:
         raise Error(_("File '%s' has invalid XML") % (localpath) )
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:8,代码来源:xmlfilepiks.py

示例3: readxml

 def readxml(self, uri, tmpDir='/tmp', sha1sum=False, compress=None, sign=None):
     uri = File.make_uri(uri)
     localpath = File.download(uri, tmpDir,sha1sum=sha1sum,compress=compress,sign=sign)
     try:
         self.doc = NoExtDtdReader.parseUri(Ft.Lib.Uri.OsPathToUri(localpath))
         return self.doc.documentElement
     except Ft.FtException, e:
         raise Error(_("File '%s' has invalid XML: %s") % (localpath, str(e)) )
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:8,代码来源:xmlfilecdom.py

示例4: readxml

 def readxml(self, uri, tmpDir = '/tmp'):
     uri = File.make_uri(uri)
     localpath = File.download(uri, tmpDir)
     try:
         self.doc = ParsePath(localpath)
         return self.doc.documentElement
     except Ft.FtException, e:
         raise Error(_("File '%s' has invalid XML: %s") % (localpath, str(e)) )
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:8,代码来源:xmlfilecdom.py

示例5: readxml

 def readxml(self, uri, tmpDir="/tmp"):
     uri = File.make_uri(uri)
     localpath = File.download(uri, tmpDir)
     try:
         self.doc = NoExtDtdReader.parseUri(Ft.Lib.Uri.OsPathToUri(localpath))
         return self.doc.documentElement
     except Ft.FtException, e:
         raise Error(_("File '%s' has invalid XML: %s") % (localpath, str(e)))
开发者ID:,项目名称:,代码行数:8,代码来源:

示例6: testRemoteRead

 def testRemoteRead(self):
     f = File('http://www.pardus.org.tr/urunler/pardus-2009.2-Geronticus_eremita-surum-notlari-tr.html', File.read)
     r = f.readlines()
     assert (len(r) > 0)
开发者ID:PisiLinuxNew,项目名称:pisi,代码行数:4,代码来源:filetest.py

示例7: testMakeUri

 def testMakeUri(self):
     self.spec = SpecFile()
     self.url = uri.URI(self.spec.source.archive.uri)
     f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     self.assert_(f.make_uri('uri'))
开发者ID:Tayyib,项目名称:uludag,代码行数:5,代码来源:filetest.py

示例8: check_signature

 def check_signature(self, filename, repo):
     tmpdir = os.path.join(ctx.config.index_dir(), repo)
     File.check_signature(filename, tmpdir)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:3,代码来源:index.py

示例9: testIsatty

 def testIsatty(self):
     f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     assert not f.isatty()
开发者ID:Tayyib,项目名称:uludag,代码行数:3,代码来源:filetest.py

示例10: writexml

 def writexml(self, uri, tmpDir = '/tmp', sha1sum=False, compress=None, sign=None):
     f = File(uri, File.write, sha1sum=sha1sum, compress=compress, sign=sign)
     PrettyPrint(self.rootNode(), stream = f)
     f.close()
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:4,代码来源:xmlfilecdom.py

示例11: testLocalFile

 def testLocalFile(self):
     f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     r = f.readlines()
     assert (len(r) > 0)
开发者ID:Pardus-Linux,项目名称:pisi,代码行数:4,代码来源:filetest.py

示例12: testFileNo

 def testFileNo(self):
     f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     assert not 3 == f.fileno()
开发者ID:Tayyib,项目名称:uludag,代码行数:3,代码来源:filetest.py

示例13: testDecompress

 def testDecompress(self):
     localfile = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     compress = File('repos/contrib-2007/pisi-index.xml', File.read)
     self.assert_(File.decompress(localfile,compress))
开发者ID:Pardus-Linux,项目名称:pisi,代码行数:4,代码来源:filetest.py

示例14: writexml

 def writexml(self, uri, tmpDir="/tmp", sha1sum=False, compress=None, sign=None):
     f = File(uri, File.write, sha1sum=sha1sum, compress=compress, sign=sign)
     f.write(self.doc.toPrettyString())
     f.close()
开发者ID:,项目名称:,代码行数:4,代码来源:

示例15: download

 def download(self, uri, transferdir):
     # fix auth info and download
     uri = File.make_uri(uri)
     if self.authinfo:
         uri.set_auth_info(self.authinfo)
     File.download(uri, transferdir)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:6,代码来源:build.py


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