From aa09fad0d952319c651ad2c5d88af43002fd0f47 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 6 Feb 2008 14:03:45 +0000 Subject: [PATCH] pisi copies already existing local file to /tmp before reading When "pisi info pkgname" is run, pisi finds the related metadata.xml file under /var/lib/pisi/package/pkgname/metadata.xml. But then it copies the file to /tmp before reading it. Fix this weirdness by figuring remote and local files and read the localfile from its location. BUG:FIXED:5417 --- pisi/pxml/xmlfile.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pisi/pxml/xmlfile.py b/pisi/pxml/xmlfile.py index 3a46af6c..34b85af0 100644 --- a/pisi/pxml/xmlfile.py +++ b/pisi/pxml/xmlfile.py @@ -62,23 +62,19 @@ class XmlFile(object): except Exception, e: raise Error(_("String '%s' has invalid XML") % (xml)) - def readxmlfile(self, f): - raise Exception("not implemented") - try: - self.doc = iks.parse(f) - return self.doc - except Exception, e: - raise Error(_("File '%s' has invalid XML") % (f) ) - - def readxml(self, uri, tmpDir='/tmp', sha1sum=False, compress=None, sign=None, copylocal = False): + uri = pisi.file.File.make_uri(uri) - #try: - localpath = pisi.file.File.download(uri, tmpDir, sha1sum=sha1sum, - compress=compress,sign=sign, copylocal=copylocal) - #except IOError, e: - # raise Error(_("Cannot read URI %s: %s") % (uri, unicode(e)) ) + + if uri.is_local_file(): + # this is a local file + localpath = uri.path() + else: + # this is a remote file, first download it into tmpDir + localpath = pisi.file.File.download(uri, tmpDir, sha1sum=sha1sum, + compress=compress,sign=sign, copylocal=copylocal) + try: self.doc = iks.parse(localpath) return self.doc