diff --git a/yum/misc.py b/yum/misc.py index 5a59ee4..a587eb6 100644 --- a/yum/misc.py +++ b/yum/misc.py @@ -565,6 +565,16 @@ def to_str(obj): obj = str(obj) return obj +def to_xml(item, attrib=False): + import xml.sax.saxutils + item = to_utf8(item) # verify this does enough conversion + item = item.rstrip() + if attrib: + item = xml.sax.saxutils.escape(item, entities={'"':"""}) + else: + item = xml.sax.saxutils.escape(item) + return item + def get_my_lang_code(): import locale mylang = locale.getlocale() diff --git a/yum/packages.py b/yum/packages.py index 527b4a5..400962a 100644 --- a/yum/packages.py +++ b/yum/packages.py @@ -565,6 +565,12 @@ class YumAvailablePackage(PackageObject, RpmBase): return self._committime_ret committime = property(_committime) + + # FIXME test this to see if it causes hell elsewhere + def _checksum(self): + "Returns the 'default' checksum" + return self.checksums[0][1] + checksum = property(_checksum) def getDiscNum(self): if self.basepath is None: @@ -730,6 +736,250 @@ class YumAvailablePackage(PackageObject, RpmBase): csumid = 0 self._checksums.append((ctype, csum, csumid)) +# from here down this is for dumping a package object back out to metadata + + + def _return_remote_location(self): + # break self.remote_url up into smaller pieces + base = os.path.dirname(self.remote_url) + href = os.path.basename(self.remote_url) + msg = """\n""" % ( + misc.to_xml(base,attrib=True), misc.to_xml(href, attrib=True)) + return msg + + def _dump_base_items(self): + + packager = url = '' + if self.packager: + packager = misc.to_xml(self.packager) + + if self.url: + url = misc.to_xml(self.url) + + msg = """ + %s + %s + + %s + %s + %s + %s + %s +