* autoxml, xmlfile: implement uri support for downloading remote files

* disable minidom
This commit is contained in:
Eray Özkural
2005-11-19 19:20:54 +00:00
parent a49ed6c33a
commit 236bada881
5 changed files with 17 additions and 10 deletions
+4 -3
View File
@@ -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
+4 -4
View File
@@ -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
+1
View File
@@ -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 *
+1
View File
@@ -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 *
+7 -3
View File
@@ -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()