本文整理汇总了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."))
示例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) )
示例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)) )
示例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)) )
示例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)))
示例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)
示例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'))
示例8: check_signature
def check_signature(self, filename, repo):
tmpdir = os.path.join(ctx.config.index_dir(), repo)
File.check_signature(filename, tmpdir)
示例9: testIsatty
def testIsatty(self):
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
assert not f.isatty()
示例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()
示例11: testLocalFile
def testLocalFile(self):
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
r = f.readlines()
assert (len(r) > 0)
示例12: testFileNo
def testFileNo(self):
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
assert not 3 == f.fileno()
示例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))
示例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()
示例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)