Ejemplo n.º 1
0
    def dump_xml(self):
        msg = ""
        top = """<data type="%s">\n""" % to_xml(self.type, attrib=True)
        msg += top
        
        for (data, xmlname) in [('checksum', 'checksum'),('openchecksum', 'open-checksum')]:
            if hasattr(self, data):
                val = getattr(self, data)
                if val[0]:
                    d_xml = """  <%s type="%s">%s</%s>\n""" % (xmlname,
                                       to_xml(val[0], attrib=True), 
                                       to_xml(val[1]), xmlname)
                    msg += d_xml

        if hasattr(self, 'location'):
            val = getattr(self, 'location')
            if val[1]:
                loc = """  <location href="%s"/>\n""" % to_xml(val[1], attrib=True)
                if val[0]:
                    loc = """  <location xml:base="%s" href="%s"/>\n""" % (
                       to_xml(val[0], attrib=True), to_xml(val[1], attrib=True))
                msg += loc
            
        for (data,xmlname) in [('timestamp', 'timestamp'),
                               ('dbversion', 'database_version'),
                               ('size','size'), ('opensize', 'open-size')]:
            val = getattr(self, data)
            if val:
                d_xml = """  <%s>%s</%s>\n""" % (xmlname, to_xml(val), 
                                                 xmlname)
                msg += d_xml

        bottom = """</data>\n"""
        msg += bottom
        return msg
Ejemplo n.º 2
0
    def dump_xml(self):
        msg = ""
        
        top = """<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">\n"""
        msg += top
        if self.revision:
            rev = """ <revision>%s</revision>\n""" % to_xml(self.revision)
            msg += rev
        
        if self.tags['content'] or self.tags['distro'] or self.tags['repo']:
            tags = """ <tags>\n"""
            for item in self.tags['content']:
                tag = """   <content>%s</content>\n""" % (to_xml(item))
                tags += tag
            for item in self.tags['repo']:
                tag = """   <repo>%s</repo>\n""" % (to_xml(item))
                tags += tag
            for (cpeid, item) in self.tags['distro']:
                itemlist = list(item) # frellingsets.
                if cpeid:
                    tag = """   <distro cpeid="%s">%s</distro>\n""" % (
                                to_xml(cpeid, attrib=True), to_xml(itemlist[0]))
                else:
                    tag = """   <distro>%s</distro>\n""" % (to_xml(itemlist[0]))
                tags += tag
            tags += """ </tags>\n"""
            msg += tags
        
        for md in self.repoData.values():
            msg += md.dump_xml()
        
        msg += """</repomd>\n"""

        return msg
Ejemplo n.º 3
0
    def dump_xml(self):
        msg = ""
        top = """<data type="%s">\n""" % to_xml(self.type, attrib=True)
        msg += top

        for (data, xmlname) in [('checksum', 'checksum'),
                                ('openchecksum', 'open-checksum')]:
            if hasattr(self, data):
                val = getattr(self, data)
                if val[0]:
                    d_xml = """  <%s type="%s">%s</%s>\n""" % (
                        xmlname, to_xml(val[0], attrib=True), to_xml(
                            val[1]), xmlname)
                    msg += d_xml

        if hasattr(self, 'location'):
            val = getattr(self, 'location')
            if val[1]:
                loc = """  <location href="%s"/>\n""" % to_xml(val[1],
                                                               attrib=True)
                if val[0]:
                    loc = """  <location xml:base="%s" href="%s"/>\n""" % (
                        to_xml(val[0], attrib=True), to_xml(val[1],
                                                            attrib=True))
                msg += loc

        for (data, xmlname) in [('timestamp', 'timestamp'),
                                ('dbversion', 'database_version'),
                                ('size', 'size'), ('opensize', 'open-size')]:
            val = getattr(self, data)
            if val:
                d_xml = """  <%s>%s</%s>\n""" % (xmlname, to_xml(val), xmlname)
                msg += d_xml

        for delta in self.deltas:
            # change tag to "delta" and increase indent
            body = '\n  '.join(delta.dump_xml().split('\n')[1:-2])
            msg += '  <delta>\n  %s\n  </delta>\n' % body

        bottom = """</data>\n"""
        msg += bottom
        return msg
Ejemplo n.º 4
0
    def dump_xml(self):
        msg = ""
        top = """<data type="%s">\n""" % to_xml(self.type, attrib=True)
        msg += top
        
        for (data, xmlname) in [('checksum', 'checksum'),('openchecksum', 'open-checksum')]:
            if hasattr(self, data):
                val = getattr(self, data)
                if val[0]:
                    d_xml = """  <%s type="%s">%s</%s>\n""" % (xmlname,
                                       to_xml(val[0], attrib=True), 
                                       to_xml(val[1]), xmlname)
                    msg += d_xml

        if hasattr(self, 'location'):
            val = getattr(self, 'location')
            if val[1]:
                loc = """  <location href="%s"/>\n""" % to_xml(val[1], attrib=True)
                if val[0]:
                    loc = """  <location xml:base="%s" href="%s"/>\n""" % (
                       to_xml(val[0], attrib=True), to_xml(val[1], attrib=True))
                msg += loc
            
        for (data,xmlname) in [('timestamp', 'timestamp'),
                               ('dbversion', 'database_version'),
                               ('size','size'), ('opensize', 'open-size')]:
            val = getattr(self, data)
            if val:
                d_xml = """  <%s>%s</%s>\n""" % (xmlname, to_xml(val), 
                                                 xmlname)
                msg += d_xml

        for delta in self.deltas:
            # change tag to "delta" and increase indent
            body = '\n  '.join(delta.dump_xml().split('\n')[1:-2])
            msg += '  <delta>\n  %s\n  </delta>\n' % body

        bottom = """</data>\n"""
        msg += bottom
        return msg
Ejemplo n.º 5
0
    def dump_xml(self):
        msg = ""

        top = """<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">\n"""
        msg += top
        if self.revision:
            rev = """ <revision>%s</revision>\n""" % to_xml(self.revision)
            msg += rev

        if self.tags['content'] or self.tags['distro'] or self.tags['repo']:
            tags = """ <tags>\n"""
            for item in self.tags['content']:
                tag = """   <content>%s</content>\n""" % (to_xml(item))
                tags += tag
            for item in self.tags['repo']:
                tag = """   <repo>%s</repo>\n""" % (to_xml(item))
                tags += tag
            distro = self.tags['distro']
            if isinstance(distro, dict):
                lst = []
                for cpeid in sorted(distro):
                    for item in sorted(distro[cpeid]):
                        lst.append((cpeid, item))
                distro = lst
            for (cpeid, item) in distro:
                if cpeid:
                    tag = """   <distro cpeid="%s">%s</distro>\n""" % (to_xml(
                        cpeid, attrib=True), to_xml(item))
                else:
                    tag = """   <distro>%s</distro>\n""" % (to_xml(item))
                tags += tag
            tags += """ </tags>\n"""
            msg += tags

        for md in self.repoData.values():
            msg += md.dump_xml()

        msg += """</repomd>\n"""

        return msg
Ejemplo n.º 6
0
    def dump_xml(self):
        msg = ""
        
        top = """<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">\n"""
        msg += top
        if self.revision:
            rev = """ <revision>%s</revision>\n""" % to_xml(self.revision)
            msg += rev
        
        if self.tags['content'] or self.tags['distro'] or self.tags['repo']:
            tags = """ <tags>\n"""
            for item in self.tags['content']:
                tag = """   <content>%s</content>\n""" % (to_xml(item))
                tags += tag
            for item in self.tags['repo']:
                tag = """   <repo>%s</repo>\n""" % (to_xml(item))
                tags += tag
            distro = self.tags['distro']
            if isinstance(distro, dict):
                lst = []
                for cpeid in sorted(distro):
                    for item in sorted(distro[cpeid]):
                        lst.append((cpeid, item))
                distro = lst
            for (cpeid, item) in distro:
                if cpeid:
                    tag = """   <distro cpeid="%s">%s</distro>\n""" % (
                                to_xml(cpeid, attrib=True), to_xml(item))
                else:
                    tag = """   <distro>%s</distro>\n""" % (to_xml(item))
                tags += tag
            tags += """ </tags>\n"""
            msg += tags
        
        for md in self.repoData.values():
            msg += md.dump_xml()
        
        msg += """</repomd>\n"""

        return msg
Ejemplo n.º 7
0
    def xml(self):
        """Generate the xml for this update notice object"""
        msg = """
<update from="%s" status="%s" type="%s" version="%s">
  <id>%s</id>
  <title>%s</title>
  <release>%s</release>
  <issued date="%s"/>
  <description>%s</description>\n""" % (to_xml(self._md['from']),
                to_xml(self._md['status']), to_xml(self._md['type']),
                to_xml(self._md['version']), to_xml(self._md['update_id']),
                to_xml(self._md['title']), to_xml(self._md['release']),
                to_xml(self._md['issued'], attrib=True),
                to_xml(self._md['description']))

        if self._md['summary']:
            msg += """  <summary>%s</summary>\n""" % (to_xml(self._md['summary']))
        if self._md['solution']:
            msg += """  <solution>%s</solution>\n""" % (to_xml(self._md['solution']))
        if self._md['rights']:
            msg += """  <rights>%s</rights>\n""" % (to_xml(self._md['rights']))        
        if self._md['severity']:
            msg += """  <severity>%s</severity>\n""" % (to_xml(self._md['severity']))

        if self._md['references']:
            msg += """  <references>\n"""
            for ref in self._md['references']:
                if ref['title']:
                    msg += """    <reference href="%s" id="%s" title="%s" type="%s"/>\n""" % (
                    to_xml(ref['href'], attrib=True), to_xml(ref['id'], attrib=True),
                    to_xml(ref['title'], attrib=True), to_xml(ref['type'], attrib=True))
                else:
                    msg += """    <reference href="%s" id="%s"  type="%s"/>\n""" % (
                    to_xml(ref['href'], attrib=True), to_xml(ref['id'], attrib=True),
                    to_xml(ref['type'], attrib=True))

            msg += """  </references>\n"""
        
        if self._md['pkglist']:
            msg += """  <pkglist>\n"""
            for coll in self._md['pkglist']:
                msg += """    <collection short="%s">\n      <name>%s</name>\n""" % (
                      to_xml(coll['short'], attrib=True),
                      to_xml(coll['name']))
  
                for pkg in coll['packages']:
                    msg += """      <package arch="%s" name="%s" release="%s" src="%s" version="%s">
        <filename>%s</filename>
      </package>\n""" % (to_xml(pkg['arch'], attrib=True),
                                to_xml(pkg['name'], attrib=True),
                                to_xml(pkg['release'], attrib=True),
                                to_xml(pkg['src'], attrib=True),
                                to_xml(pkg['version'], attrib=True),
                                to_xml(pkg['filename']))
                msg += """    </collection>\n"""
                msg += """  </pkglist>\n"""
        msg += """</update>\n"""
        return msg
Ejemplo n.º 8
0
    def xml(self):
        """Generate the xml for this update notice object"""
        msg = """
<update from="%s" status="%s" type="%s" version="%s">
  <id>%s</id>
  <title>%s</title>
  <release>%s</release>
  <issued date="%s"/>
  <description>%s</description>\n""" % (
            to_xml(self._md['from']), to_xml(self._md['status']),
            to_xml(self._md['type']), to_xml(
                self._md['version']), to_xml(self._md['update_id']),
            to_xml(self._md['title']), to_xml(
                self._md['release']), to_xml(self._md['issued'], attrib=True),
            to_xml(self._md['description']))

        if self._md['summary']:
            msg += """  <summary>%s</summary>\n""" % (to_xml(
                self._md['summary']))
        if self._md['solution']:
            msg += """  <solution>%s</solution>\n""" % (to_xml(
                self._md['solution']))
        if self._md['rights']:
            msg += """  <rights>%s</rights>\n""" % (to_xml(self._md['rights']))
        if self._md['severity']:
            msg += """  <severity>%s</severity>\n""" % (to_xml(
                self._md['severity']))

        if self._md['references']:
            msg += """  <references>\n"""
            for ref in self._md['references']:
                if ref['title']:
                    msg += """    <reference href="%s" id="%s" title="%s" type="%s"/>\n""" % (
                        to_xml(ref['href'],
                               attrib=True), to_xml(ref['id'], attrib=True),
                        to_xml(ref['title'],
                               attrib=True), to_xml(ref['type'], attrib=True))
                else:
                    msg += """    <reference href="%s" id="%s"  type="%s"/>\n""" % (
                        to_xml(ref['href'],
                               attrib=True), to_xml(ref['id'], attrib=True),
                        to_xml(ref['type'], attrib=True))

            msg += """  </references>\n"""

        if self._md['pkglist']:
            msg += """  <pkglist>\n"""
            for coll in self._md['pkglist']:
                msg += """    <collection short="%s">\n      <name>%s</name>\n""" % (
                    to_xml(coll['short'], attrib=True), to_xml(coll['name']))

                for pkg in coll['packages']:
                    msg += """      <package arch="%s" name="%s" release="%s" src="%s" version="%s">
        <filename>%s</filename>
      </package>\n""" % (to_xml(pkg['arch'],
                                attrib=True), to_xml(pkg['name'], attrib=True),
                         to_xml(pkg['release'],
                                attrib=True), to_xml(pkg['src'], attrib=True),
                         to_xml(pkg['version'],
                                attrib=True), to_xml(pkg['filename']))
                msg += """    </collection>\n"""
                msg += """  </pkglist>\n"""
        msg += """</update>\n"""
        return msg