* get metadata and files info from pisi package without extracting somewhere.

This commit is contained in:
Faik Uygur
2006-09-28 08:51:57 +00:00
parent 578135a71c
commit 900b48a20b
3 changed files with 39 additions and 0 deletions
+12
View File
@@ -105,6 +105,18 @@ class Package:
self.extract_files([ctx.const.metadata_xml, ctx.const.files_xml], outdir)
self.extract_dir('config', outdir)
def get_metadata(self):
"""reads metadata.xml from the PiSi package and returns MetaData object"""
md = MetaData()
md.parse(self.impl.read_file(ctx.const.metadata_xml))
return md
def get_files(self):
"""reads files.xml from the PiSi package and returns Files object"""
files = Files()
files.parse(self.impl.read_file(ctx.const.files_xml))
return files
def read(self, outdir = None):
if not outdir:
outdir = ctx.config.tmp_dir()
+19
View File
@@ -412,6 +412,24 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.__ne__ = notequal
if xmlfile_support:
def parse(self, xml, keepDoc = False):
"parse XML string and decode it into a python object"
self.parsexml(xml)
errs = []
self.decode(self.rootNode(), errs)
if errs:
errs.append(_("autoxml.parse: String '%s' has errors") % xml)
raise Error(*errs)
if hasattr(self, 'read_hook'):
self.read_hook(errs)
if not keepDoc:
self.unlink() # get rid of the tree
errs = self.errors()
if errs:
errs.append(_("autoxml.parse: String '%s' has errors") % xml)
def read(self, uri, keepDoc = False, tmpDir = '/tmp',
sha1sum = False, compress = None, sign = None, copylocal = False):
"read XML file and decode it into a python object"
@@ -454,6 +472,7 @@ class autoxml(oo.autosuper, oo.autoprop):
cls.read = read
cls.write = write
cls.parse = parse
def gen_attr_member(cls, attr):
+8
View File
@@ -54,6 +54,14 @@ class XmlFile(object):
def rootNode(self):
"""returns root document element"""
return self.doc
def parsexml(self, xml):
"""parses xml string and returns DOM"""
try:
self.doc = iks.parseString(xml)
return self.doc
except Exception, e:
raise Error(_("String '%s' has invalid XML") % (xml))
def readxmlfile(self, file):
raise Exception("not implemented")