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