diff --git a/TODO b/TODO index ff0843c2..6aca5c4a 100644 --- a/TODO +++ b/TODO @@ -74,9 +74,10 @@ Legend: 3. Beta - - improve url support, it's a little dumb at the moment - - devise a File class that works with URLs - - consider adding "other" protocols + / improve url support, it's a little dumb at the moment + + devise a File class that works with URLs + + add URL support to autoxml + ? consider adding "other" protocols - removable media: media:// + info cmd: reverse dependencies of a package diff --git a/pisi/pxml/autoxml.py b/pisi/pxml/autoxml.py index 71b8ea18..523eb986 100644 --- a/pisi/pxml/autoxml.py +++ b/pisi/pxml/autoxml.py @@ -397,9 +397,9 @@ class autoxml(oo.autosuper, oo.autoprop): cls.__ne__ = notequal if xmlfile_support: - def read(self, filename, keepDoc = False): + def read(self, uri, keepDoc = False, tmpDir = '/tmp'): "read XML file and decode it into a python object" - self.readxml(filename) + self.readxml(uri, tmpDir) errs = [] self.decode(self.rootNode(), errs) if hasattr(self, 'read_hook'): @@ -416,7 +416,7 @@ class autoxml(oo.autosuper, oo.autoprop): errs.append(_("autoxml.read: File '%s' has errors") % filename) raise Error(*errs) - def write(self, filename, keepDoc = False): + def write(self, uri, keepDoc = False, tmpDir = '/tmp'): "encode the contents of the python object into an XML file" errs = self.errors() if errs: @@ -430,7 +430,7 @@ class autoxml(oo.autosuper, oo.autoprop): if errs: errs.append(_("autoxml.write: File encoding '%s' has errors") % filename) raise Error(*errs) - self.writexml(filename) + self.writexml(uri, tmpDir) if not keepDoc: self.unlink() # get rid of the tree diff --git a/pisi/pxml/xmlext.py b/pisi/pxml/xmlext.py index ea7dbdeb..07484ca4 100644 --- a/pisi/pxml/xmlext.py +++ b/pisi/pxml/xmlext.py @@ -18,6 +18,7 @@ except: try: from xmlextcdom import * except: + raise Error('cannot find 4suite implementation') print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom' from xmlextmdom import * diff --git a/pisi/pxml/xmlfile.py b/pisi/pxml/xmlfile.py index 529018c9..c8cfe6c6 100644 --- a/pisi/pxml/xmlfile.py +++ b/pisi/pxml/xmlfile.py @@ -18,5 +18,6 @@ except: try: from xmlfilecdom import * except: + raise Error('cannot find 4suite implementation') print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom' from xmlfilemdom import * diff --git a/pisi/pxml/xmlfilecdom.py b/pisi/pxml/xmlfilecdom.py index 8805534d..41c28a97 100644 --- a/pisi/pxml/xmlfilecdom.py +++ b/pisi/pxml/xmlfilecdom.py @@ -44,6 +44,8 @@ XML_NS = unicode(XML_NAMESPACE) import pisi from pisi.pxml.xmlextcdom import * +from pisi.file import File +from pisi.util import join_path as join class Error(pisi.Error): pass @@ -66,16 +68,18 @@ class XmlFile(object): """returns root document element""" return self.doc.documentElement - def readxml(self, path): + def readxml(self, uri, tmpDir = '/tmp'): + uri = File.make_uri(uri) + localpath = File.download(uri, tmpDir) try: - self.doc = ParsePath(path) + self.doc = ParsePath(localpath) return self.doc.documentElement except Ft.FtException, e: raise Error(_("File '%s' has invalid XML: %s") % (path, str(e)) ) except exceptions.ValueError, e: raise Error(_("File '%s' not found") % path ) - def writexml(self, path): + def writexml(self, uri, tmpDir = '/tmp'): f = file(path, 'w') PrettyPrint(self.rootNode(), stream = f) f.close()