prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Support Sourceware bugs in Fedora enhanced markdown
  Many key projects reside on sourceware.org including glibc, gdb, binutils, elfutils, libabigail, systemtap etc.
  
  Could you please add markdown support for sourceware.org bugzilla (https://sourceware.org/bugzilla/)?
  
  I suggest a unified markup of SWBZ#XXXX or SW#XXXX for all projects on the main sourceware bugzilla instance.
  
  Likewise gcc compiler bugs are also on sourceware but use a distinct instance (https://gcc.gnu.org/bugzilla/)
  
  I suggest a markup of GCC#XXXX for gcc bugs.
  
  Thank you!
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bodhi/server/ffmarkdown.py`
  Content:
  ```
  1 # Copyright © 2014-2019 Red Hat, Inc. and others.
  2 #
  3 # This file is part of Bodhi.
  4 #
  5 # This program is free software; you can redistribute it and/or
  6 # modify it under the terms of the GNU General Public License
  7 # as published by the Free Software Foundation; either version 2
  8 # of the License, or (at your option) any later version.
  9 #
  10 # This program is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 # GNU General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU General Public License
  16 # along with this program; if not, write to the Free Software
  17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
  18 # USA.
  19 """
  20 Fedora-flavored Markdown.
  21 
  22 Author: Ralph Bean <rbean@redhat.com>
  23 """
  24 
  25 from markdown.extensions import Extension
  26 import markdown.inlinepatterns
  27 import markdown.postprocessors
  28 import markdown.util
  29 import pyramid.threadlocal
  30 
  31 from bodhi import MENTION_RE
  32 
  33 
  34 BUGZILLA_RE = r'([a-zA-Z]+)(#[0-9]{5,})'
  35 
  36 
  37 def user_url(name):
  38     """
  39     Return a URL to the given username.
  40 
  41     Args:
  42         name (basestring): The username of the user we want a URL for.
  43     Returns:
  44         basestring: A URL to the requested user.
  45     """
  46     request = pyramid.threadlocal.get_current_request()
  47     return request.route_url('user', name=name)
  48 
  49 
  50 def bug_url(tracker, idx):
  51     """
  52     Return the URL for the given bug.
  53 
  54     Args:
  55         tracker (basestring): Which bug tracker is being referenced. May be any of 'fedora',
  56             'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', or 'rhbz'.
  57         idx (basestring or int): The bug number.
  58     Returns:
  59         basestring: The URL of the given bug.
  60     Raises:
  61         KeyError: If the given tracker is not supported by this function.
  62     """
  63     try:
  64         return {
  65             'fedora': "https://bugzilla.redhat.com/show_bug.cgi?id=%s",
  66             'gnome': "https://bugzilla.gnome.org/show_bug.cgi?id=%s",
  67             'kde': "https://bugs.kde.org/show_bug.cgi?id=%s",
  68             'mozilla': "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
  69             'pear': "http://pear.php.net/bugs/bug.php?id=%s",
  70             'perl': "https://rt.cpan.org/Public/Bug/Display.html?id=%s",
  71             'php': "https://bugs.php.net/bug.php?id=%s",
  72             'python': "https://bugs.python.org/issue%s",
  73             'rh': "https://bugzilla.redhat.com/show_bug.cgi?id=%s",
  74             'rhbz': "https://bugzilla.redhat.com/show_bug.cgi?id=%s"}[tracker.lower()] % idx
  75 
  76     except KeyError:
  77         return None
  78 
  79 
  80 class MentionPattern(markdown.inlinepatterns.Pattern):
  81     """Match username mentions and point to their profiles."""
  82 
  83     def handleMatch(self, m):
  84         """
  85         Build and return an Element that links to the matched User's profile.
  86 
  87         Args:
  88             m (re.MatchObject): The regex match on the username.
  89         Return:
  90             xml.etree.Element: An html anchor referencing the user's profile.
  91         """
  92         el = markdown.util.etree.Element("a")
  93         name = markdown.util.AtomicString(m.group(2))
  94         el.set('href', user_url(name[1:]))
  95         el.text = name
  96         return el
  97 
  98 
  99 class BugzillaPattern(markdown.inlinepatterns.Pattern):
  100     """Match bug tracker patterns."""
  101 
  102     def handleMatch(self, m):
  103         """
  104         Build and return an Element that links to the referenced bug.
  105 
  106         Args:
  107             m (re.MatchObject): The regex match on the bug.
  108         Returns:
  109             xml.etree.Element: An html anchor referencing the matched bug.
  110         """
  111         tracker = markdown.util.AtomicString(m.group(2))
  112         idx = markdown.util.AtomicString(m.group(3))
  113         url = bug_url(tracker, idx[1:])
  114 
  115         if url is None:
  116             return tracker + idx
  117 
  118         el = markdown.util.etree.Element("a")
  119         el.set('href', url)
  120         el.text = idx
  121         return el
  122 
  123 
  124 class SurroundProcessor(markdown.postprocessors.Postprocessor):
  125     """A postprocessor to surround the text with a markdown <div>."""
  126 
  127     def run(self, text):
  128         """
  129         Return text wrapped in a <div> with a markdown class.
  130 
  131         Args:
  132             text (str): The text to wrap in a <div>.
  133         Returns:
  134             str: The text wrapped in a <div>.
  135         """
  136         return "<div class='markdown'>" + text + "</div>"
  137 
  138 
  139 class BodhiExtension(Extension):
  140     """Bodhi's markdown Extension."""
  141 
  142     def extendMarkdown(self, md, md_globals):
  143         """
  144         Extend markdown to add our patterns and postprocessor.
  145 
  146         Args:
  147             md (Markdown): An instance of the Markdown class.
  148             md_globals (dict): Contains all the various global variables within the markdown module.
  149         """
  150         md.inlinePatterns.add('mention', MentionPattern(MENTION_RE, md), '_end')
  151         md.inlinePatterns.add('bugzilla', BugzillaPattern(BUGZILLA_RE, md), '_end')
  152         md.postprocessors.add('surround', SurroundProcessor(md), '_end')
  153
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bodhi/server/ffmarkdown.py b/bodhi/server/ffmarkdown.py
  --- a/bodhi/server/ffmarkdown.py
  +++ b/bodhi/server/ffmarkdown.py
  @@ -53,7 +53,8 @@
   
       Args:
           tracker (basestring): Which bug tracker is being referenced. May be any of 'fedora',
  -            'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', or 'rhbz'.
  +            'gcc', 'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', 'rhbz'
  +            or 'sourceware'.
           idx (basestring or int): The bug number.
       Returns:
           basestring: The URL of the given bug.
  @@ -61,17 +62,21 @@
           KeyError: If the given tracker is not supported by this function.
       """
       try:
  -        return {
  +        trackers = {
               'fedora': "https://bugzilla.redhat.com/show_bug.cgi?id=%s",
  +            'gcc': "https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%s",
               'gnome': "https://bugzilla.gnome.org/show_bug.cgi?id=%s",
               'kde': "https://bugs.kde.org/show_bug.cgi?id=%s",
               'mozilla': "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
  -            'pear': "http://pear.php.net/bugs/bug.php?id=%s",
  +            'pear': "https://pear.php.net/bugs/bug.php?id=%s",
               'perl': "https://rt.cpan.org/Public/Bug/Display.html?id=%s",
               'php': "https://bugs.php.net/bug.php?id=%s",
               'python': "https://bugs.python.org/issue%s",
               'rh': "https://bugzilla.redhat.com/show_bug.cgi?id=%s",
  -            'rhbz': "https://bugzilla.redhat.com/show_bug.cgi?id=%s"}[tracker.lower()] % idx
  +            'rhbz': "https://bugzilla.redhat.com/show_bug.cgi?id=%s",
  +            'sourceware': "https://sourceware.org/bugzilla/show_bug.cgi?id=%s"}
  +
  +        return trackers[tracker.lower()] % idx
   
       except KeyError:
           return None
  
verification_info: {"golden_diff": "diff --git a/bodhi/server/ffmarkdown.py b/bodhi/server/ffmarkdown.py\n--- a/bodhi/server/ffmarkdown.py\n+++ b/bodhi/server/ffmarkdown.py\n@@ -53,7 +53,8 @@\n \n     Args:\n         tracker (basestring): Which bug tracker is being referenced. May be any of 'fedora',\n-            'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', or 'rhbz'.\n+            'gcc', 'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', 'rhbz'\n+            or 'sourceware'.\n         idx (basestring or int): The bug number.\n     Returns:\n         basestring: The URL of the given bug.\n@@ -61,17 +62,21 @@\n         KeyError: If the given tracker is not supported by this function.\n     \"\"\"\n     try:\n-        return {\n+        trackers = {\n             'fedora': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n+            'gcc': \"https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%s\",\n             'gnome': \"https://bugzilla.gnome.org/show_bug.cgi?id=%s\",\n             'kde': \"https://bugs.kde.org/show_bug.cgi?id=%s\",\n             'mozilla': \"https://bugzilla.mozilla.org/show_bug.cgi?id=%s\",\n-            'pear': \"http://pear.php.net/bugs/bug.php?id=%s\",\n+            'pear': \"https://pear.php.net/bugs/bug.php?id=%s\",\n             'perl': \"https://rt.cpan.org/Public/Bug/Display.html?id=%s\",\n             'php': \"https://bugs.php.net/bug.php?id=%s\",\n             'python': \"https://bugs.python.org/issue%s\",\n             'rh': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n-            'rhbz': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\"}[tracker.lower()] % idx\n+            'rhbz': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n+            'sourceware': \"https://sourceware.org/bugzilla/show_bug.cgi?id=%s\"}\n+\n+        return trackers[tracker.lower()] % idx\n \n     except KeyError:\n         return None\n", "issue": "Support Sourceware bugs in Fedora enhanced markdown\nMany key projects reside on sourceware.org including glibc, gdb, binutils, elfutils, libabigail, systemtap etc.\r\n\r\nCould you please add markdown support for sourceware.org bugzilla (https://sourceware.org/bugzilla/)?\r\n\r\nI suggest a unified markup of SWBZ#XXXX or SW#XXXX for all projects on the main sourceware bugzilla instance.\r\n\r\nLikewise gcc compiler bugs are also on sourceware but use a distinct instance (https://gcc.gnu.org/bugzilla/)\r\n\r\nI suggest a markup of GCC#XXXX for gcc bugs.\r\n\r\nThank you!\n", "before_files": [{"content": "# Copyright \u00a9 2014-2019 Red Hat, Inc. and others.\n#\n# This file is part of Bodhi.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,\n# USA.\n\"\"\"\nFedora-flavored Markdown.\n\nAuthor: Ralph Bean <rbean@redhat.com>\n\"\"\"\n\nfrom markdown.extensions import Extension\nimport markdown.inlinepatterns\nimport markdown.postprocessors\nimport markdown.util\nimport pyramid.threadlocal\n\nfrom bodhi import MENTION_RE\n\n\nBUGZILLA_RE = r'([a-zA-Z]+)(#[0-9]{5,})'\n\n\ndef user_url(name):\n    \"\"\"\n    Return a URL to the given username.\n\n    Args:\n        name (basestring): The username of the user we want a URL for.\n    Returns:\n        basestring: A URL to the requested user.\n    \"\"\"\n    request = pyramid.threadlocal.get_current_request()\n    return request.route_url('user', name=name)\n\n\ndef bug_url(tracker, idx):\n    \"\"\"\n    Return the URL for the given bug.\n\n    Args:\n        tracker (basestring): Which bug tracker is being referenced. May be any of 'fedora',\n            'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', or 'rhbz'.\n        idx (basestring or int): The bug number.\n    Returns:\n        basestring: The URL of the given bug.\n    Raises:\n        KeyError: If the given tracker is not supported by this function.\n    \"\"\"\n    try:\n        return {\n            'fedora': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n            'gnome': \"https://bugzilla.gnome.org/show_bug.cgi?id=%s\",\n            'kde': \"https://bugs.kde.org/show_bug.cgi?id=%s\",\n            'mozilla': \"https://bugzilla.mozilla.org/show_bug.cgi?id=%s\",\n            'pear': \"http://pear.php.net/bugs/bug.php?id=%s\",\n            'perl': \"https://rt.cpan.org/Public/Bug/Display.html?id=%s\",\n            'php': \"https://bugs.php.net/bug.php?id=%s\",\n            'python': \"https://bugs.python.org/issue%s\",\n            'rh': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n            'rhbz': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\"}[tracker.lower()] % idx\n\n    except KeyError:\n        return None\n\n\nclass MentionPattern(markdown.inlinepatterns.Pattern):\n    \"\"\"Match username mentions and point to their profiles.\"\"\"\n\n    def handleMatch(self, m):\n        \"\"\"\n        Build and return an Element that links to the matched User's profile.\n\n        Args:\n            m (re.MatchObject): The regex match on the username.\n        Return:\n            xml.etree.Element: An html anchor referencing the user's profile.\n        \"\"\"\n        el = markdown.util.etree.Element(\"a\")\n        name = markdown.util.AtomicString(m.group(2))\n        el.set('href', user_url(name[1:]))\n        el.text = name\n        return el\n\n\nclass BugzillaPattern(markdown.inlinepatterns.Pattern):\n    \"\"\"Match bug tracker patterns.\"\"\"\n\n    def handleMatch(self, m):\n        \"\"\"\n        Build and return an Element that links to the referenced bug.\n\n        Args:\n            m (re.MatchObject): The regex match on the bug.\n        Returns:\n            xml.etree.Element: An html anchor referencing the matched bug.\n        \"\"\"\n        tracker = markdown.util.AtomicString(m.group(2))\n        idx = markdown.util.AtomicString(m.group(3))\n        url = bug_url(tracker, idx[1:])\n\n        if url is None:\n            return tracker + idx\n\n        el = markdown.util.etree.Element(\"a\")\n        el.set('href', url)\n        el.text = idx\n        return el\n\n\nclass SurroundProcessor(markdown.postprocessors.Postprocessor):\n    \"\"\"A postprocessor to surround the text with a markdown <div>.\"\"\"\n\n    def run(self, text):\n        \"\"\"\n        Return text wrapped in a <div> with a markdown class.\n\n        Args:\n            text (str): The text to wrap in a <div>.\n        Returns:\n            str: The text wrapped in a <div>.\n        \"\"\"\n        return \"<div class='markdown'>\" + text + \"</div>\"\n\n\nclass BodhiExtension(Extension):\n    \"\"\"Bodhi's markdown Extension.\"\"\"\n\n    def extendMarkdown(self, md, md_globals):\n        \"\"\"\n        Extend markdown to add our patterns and postprocessor.\n\n        Args:\n            md (Markdown): An instance of the Markdown class.\n            md_globals (dict): Contains all the various global variables within the markdown module.\n        \"\"\"\n        md.inlinePatterns.add('mention', MentionPattern(MENTION_RE, md), '_end')\n        md.inlinePatterns.add('bugzilla', BugzillaPattern(BUGZILLA_RE, md), '_end')\n        md.postprocessors.add('surround', SurroundProcessor(md), '_end')\n", "path": "bodhi/server/ffmarkdown.py"}], "after_files": [{"content": "# Copyright \u00a9 2014-2019 Red Hat, Inc. and others.\n#\n# This file is part of Bodhi.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,\n# USA.\n\"\"\"\nFedora-flavored Markdown.\n\nAuthor: Ralph Bean <rbean@redhat.com>\n\"\"\"\n\nfrom markdown.extensions import Extension\nimport markdown.inlinepatterns\nimport markdown.postprocessors\nimport markdown.util\nimport pyramid.threadlocal\n\nfrom bodhi import MENTION_RE\n\n\nBUGZILLA_RE = r'([a-zA-Z]+)(#[0-9]{5,})'\n\n\ndef user_url(name):\n    \"\"\"\n    Return a URL to the given username.\n\n    Args:\n        name (basestring): The username of the user we want a URL for.\n    Returns:\n        basestring: A URL to the requested user.\n    \"\"\"\n    request = pyramid.threadlocal.get_current_request()\n    return request.route_url('user', name=name)\n\n\ndef bug_url(tracker, idx):\n    \"\"\"\n    Return the URL for the given bug.\n\n    Args:\n        tracker (basestring): Which bug tracker is being referenced. May be any of 'fedora',\n            'gcc', 'gnome', 'kde', 'mozilla', 'pear', 'perl', 'php', 'python', 'rh', 'rhbz'\n            or 'sourceware'.\n        idx (basestring or int): The bug number.\n    Returns:\n        basestring: The URL of the given bug.\n    Raises:\n        KeyError: If the given tracker is not supported by this function.\n    \"\"\"\n    try:\n        trackers = {\n            'fedora': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n            'gcc': \"https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%s\",\n            'gnome': \"https://bugzilla.gnome.org/show_bug.cgi?id=%s\",\n            'kde': \"https://bugs.kde.org/show_bug.cgi?id=%s\",\n            'mozilla': \"https://bugzilla.mozilla.org/show_bug.cgi?id=%s\",\n            'pear': \"https://pear.php.net/bugs/bug.php?id=%s\",\n            'perl': \"https://rt.cpan.org/Public/Bug/Display.html?id=%s\",\n            'php': \"https://bugs.php.net/bug.php?id=%s\",\n            'python': \"https://bugs.python.org/issue%s\",\n            'rh': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n            'rhbz': \"https://bugzilla.redhat.com/show_bug.cgi?id=%s\",\n            'sourceware': \"https://sourceware.org/bugzilla/show_bug.cgi?id=%s\"}\n\n        return trackers[tracker.lower()] % idx\n\n    except KeyError:\n        return None\n\n\nclass MentionPattern(markdown.inlinepatterns.Pattern):\n    \"\"\"Match username mentions and point to their profiles.\"\"\"\n\n    def handleMatch(self, m):\n        \"\"\"\n        Build and return an Element that links to the matched User's profile.\n\n        Args:\n            m (re.MatchObject): The regex match on the username.\n        Return:\n            xml.etree.Element: An html anchor referencing the user's profile.\n        \"\"\"\n        el = markdown.util.etree.Element(\"a\")\n        name = markdown.util.AtomicString(m.group(2))\n        el.set('href', user_url(name[1:]))\n        el.text = name\n        return el\n\n\nclass BugzillaPattern(markdown.inlinepatterns.Pattern):\n    \"\"\"Match bug tracker patterns.\"\"\"\n\n    def handleMatch(self, m):\n        \"\"\"\n        Build and return an Element that links to the referenced bug.\n\n        Args:\n            m (re.MatchObject): The regex match on the bug.\n        Returns:\n            xml.etree.Element: An html anchor referencing the matched bug.\n        \"\"\"\n        tracker = markdown.util.AtomicString(m.group(2))\n        idx = markdown.util.AtomicString(m.group(3))\n        url = bug_url(tracker, idx[1:])\n\n        if url is None:\n            return tracker + idx\n\n        el = markdown.util.etree.Element(\"a\")\n        el.set('href', url)\n        el.text = idx\n        return el\n\n\nclass SurroundProcessor(markdown.postprocessors.Postprocessor):\n    \"\"\"A postprocessor to surround the text with a markdown <div>.\"\"\"\n\n    def run(self, text):\n        \"\"\"\n        Return text wrapped in a <div> with a markdown class.\n\n        Args:\n            text (str): The text to wrap in a <div>.\n        Returns:\n            str: The text wrapped in a <div>.\n        \"\"\"\n        return \"<div class='markdown'>\" + text + \"</div>\"\n\n\nclass BodhiExtension(Extension):\n    \"\"\"Bodhi's markdown Extension.\"\"\"\n\n    def extendMarkdown(self, md, md_globals):\n        \"\"\"\n        Extend markdown to add our patterns and postprocessor.\n\n        Args:\n            md (Markdown): An instance of the Markdown class.\n            md_globals (dict): Contains all the various global variables within the markdown module.\n        \"\"\"\n        md.inlinePatterns.add('mention', MentionPattern(MENTION_RE, md), '_end')\n        md.inlinePatterns.add('bugzilla', BugzillaPattern(BUGZILLA_RE, md), '_end')\n        md.postprocessors.add('surround', SurroundProcessor(md), '_end')\n", "path": "bodhi/server/ffmarkdown.py"}]}