コード例 #1
0
ファイル: readMetadata.py プロジェクト: proddi/createrepo
    def _return_remote_location(self):

        if self.basepath:
            msg = """<location xml:base="%s" href="%s"/>\n""" % (
                                     misc.to_xml(self.basepath, attrib=True),
                                     misc.to_xml(self.relativepath, attrib=True))
        else:
            msg = """<location href="%s"/>\n""" % misc.to_xml(self.relativepath, attrib=True)

        return msg  
コード例 #2
0
ファイル: updateinfo.py プロジェクト: preethit/pulp_rpm
def encode_epoch(erratum):
    """
    This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1020415

    Yum forgot to call it's "to_xml" function on the "epoch" field only. Also,
    that function does not convert anything to XML. It only prepares the input
    for inclusion in an XML document, mostly by decoding it from unicode to a
    string. This is known to affect yum 3.4.3-111 and newer. Note that earlier
    builds of 3.4.3 did not have this problem; they did in fact change the
    code without bumping the version, which can cause confusion.

    The yum bug is being tracked here:
    https://bugzilla.redhat.com/show_bug.cgi?id=1020540

    :param erratum: an erratum whose package epochs should be converted to a
                    yum-friendly state.
    :type  erratum: pulp.plugins.model.Unit
    """
    for packages_dict in erratum.metadata['pkglist']:
        for package in packages_dict['packages']:
            if 'epoch' in package:
                # yum calls this on every other field except this one, which can
                # cause problems if there are non-ascii characters in published
                # XML file.
                package['epoch'] = to_xml(package['epoch'])
コード例 #3
0
def encode_epoch(erratum):
    """
    This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1020415

    Yum forgot to call it's "to_xml" function on the "epoch" field only. Also,
    that function does not convert anything to XML. It only prepares the input
    for inclusion in an XML document, mostly by decoding it from unicode to a
    string. This is known to affect yum 3.4.3-111 and newer. Note that earlier
    builds of 3.4.3 did not have this problem; they did in fact change the
    code without bumping the version, which can cause confusion.

    The yum bug is being tracked here:
    https://bugzilla.redhat.com/show_bug.cgi?id=1020540

    :param erratum: an erratum whose package epochs should be converted to a
                    yum-friendly state.
    :type  erratum: pulp.plugins.model.Unit
    """
    for packages_dict in erratum.metadata['pkglist']:
        for package in packages_dict['packages']:
            if 'epoch' in package:
                # yum calls this on every other field except this one, which can
                # cause problems if there are non-ascii characters in published
                # XML file.
                package['epoch'] = to_xml(package['epoch'])
コード例 #4
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['updated']:
            # include the updated date in the generated xml
            msg += """ <updated date="%s"/>\n""" % (to_xml(self._md['updated'], attrib=True))
        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" epoch="%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['epoch'] or '0', attrib=True),
                                to_xml(pkg['filename']))
                msg += """    </collection>\n"""
            msg += """  </pkglist>\n"""
        msg += """</update>\n"""
        return msg
コード例 #5
0
ファイル: update_md.py プロジェクト: z0by/yum
    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["updated"]:
            # include the updated date in the generated xml
            msg += """ <updated date="%s"/>\n""" % (to_xml(self._md["updated"], attrib=True))
        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