We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
'Is reporter a Mozillian' as a feature
The first implementation will simply check if an email contains "@mozilla.com" or "@mozilla.org".

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bugbug/bug_features.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 # You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 import re
7 
8 import pandas as pd
9 from sklearn.base import BaseEstimator
10 from sklearn.base import TransformerMixin
11 
12 from bugbug import bug_snapshot
13 
14 
15 def field(bug, field):
16     if field in bug and bug[field] != '---':
17         return bug[field]
18 
19     return None
20 
21 
22 class has_str(object):
23     def __call__(self, bug):
24         return field(bug, 'cf_has_str')
25 
26 
27 class has_regression_range(object):
28     def __call__(self, bug):
29         return field(bug, 'cf_has_regression_range')
30 
31 
32 class has_crash_signature(object):
33     def __call__(self, bug):
34         return 'cf_crash_signature' in bug and bug['cf_crash_signature'] != ''
35 
36 
37 class keywords(object):
38     def __init__(self, to_ignore=set()):
39         self.to_ignore = to_ignore
40 
41     def __call__(self, bug):
42         keywords = []
43         subkeywords = []
44         for keyword in bug['keywords']:
45             if keyword in self.to_ignore:
46                 continue
47 
48             keywords.append(keyword)
49 
50             if keyword.startswith('sec-'):
51                 subkeywords.append('sec-')
52             elif keyword.startswith('csectype-'):
53                 subkeywords.append('csectype-')
54         return keywords + subkeywords
55 
56 
57 class severity(object):
58     def __call__(self, bug):
59         return field(bug, 'severity')
60 
61 
62 class is_coverity_issue(object):
63     def __call__(self, bug):
64         return re.search('[CID ?[0-9]+]', bug['summary']) is not None or re.search('[CID ?[0-9]+]', bug['whiteboard']) is not None
65 
66 
67 class has_url(object):
68     def __call__(self, bug):
69         return bug['url'] != ''
70 
71 
72 class has_w3c_url(object):
73     def __call__(self, bug):
74         return 'w3c' in bug['url']
75 
76 
77 class has_github_url(object):
78     def __call__(self, bug):
79         return 'github' in bug['url']
80 
81 
82 class whiteboard(object):
83     def __call__(self, bug):
84         ret = []
85 
86         # TODO: Add any [XXX:YYY] that appears in the whiteboard as [XXX: only
87 
88         for elem in ['memshrink', '[ux]']:
89             if elem in bug['whiteboard'].lower():
90                 ret.append(elem)
91 
92         return ret
93 
94 
95 class patches(object):
96     def __call__(self, bug):
97         return sum(1 for a in bug['attachments'] if a['is_patch'] or a['content_type'] in ['text/x-review-board-request', 'text/x-phabricator-request'])
98 
99 
100 class landings(object):
101     def __call__(self, bug):
102         return sum(1 for c in bug['comments'] if '://hg.mozilla.org/' in c['text'])
103 
104 
105 class title(object):
106     def __call__(self, bug):
107         ret = []
108 
109         keywords = [
110             'fail',
111         ]
112         for keyword in keywords:
113             if keyword in bug['summary'].lower():
114                 ret.append(keyword)
115 
116         return ret
117 
118 
119 class product(object):
120     def __call__(self, bug):
121         return bug['product']
122 
123 
124 class component(object):
125     def __call__(self, bug):
126         return bug['component']
127 
128 
129 def cleanup_url(text):
130     text = re.sub(r'http[s]?://(hg.mozilla|searchfox|dxr.mozilla)\S+', '__CODE_REFERENCE_URL__', text)
131     return re.sub(r'http\S+', '__URL__', text)
132 
133 
134 def cleanup_fileref(text):
135     return re.sub(r'\w+\.py\b|\w+\.json\b|\w+\.js\b|\w+\.jsm\b|\w+\.html\b|\w+\.css\b|\w+\.c\b|\w+\.cpp\b|\w+\.h\b', '__FILE_REFERENCE__', text)
136 
137 
138 def cleanup_responses(text):
139     return re.sub('>[^\n]+', ' ', text)
140 
141 
142 def cleanup_hex(text):
143     return re.sub(r'\b0[xX][0-9a-fA-F]+\b', '__HEX_NUMBER__', text)
144 
145 
146 def cleanup_dll(text):
147     return re.sub(r'\w+\.dll\b', '__DLL_NAME__', text)
148 
149 
150 def cleanup_synonyms(text):
151     synonyms = [
152         ('safemode', ['safemode', 'safe mode']),
153         ('str', ['str', 'steps to reproduce', 'repro steps']),
154         ('uaf', ['uaf', 'use after free', 'use-after-free']),
155         ('asan', ['asan', 'address sanitizer', 'addresssanitizer']),
156         ('permafailure', ['permafailure', 'permafailing', 'permafail', 'perma failure', 'perma failing', 'perma fail', 'perma-failure', 'perma-failing', 'perma-fail']),
157     ]
158 
159     for synonym_group, synonym_list in synonyms:
160         text = re.sub('|'.join(synonym_list), synonym_group, text, flags=re.IGNORECASE)
161 
162     return text
163 
164 
165 def cleanup_crash(text):
166     return re.sub(r'bp-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{6}[0-9]{6}\b', '__CRASH_STATS_LINK__', text)
167 
168 
169 class BugExtractor(BaseEstimator, TransformerMixin):
170     def __init__(self, feature_extractors, cleanup_functions, rollback=False, rollback_when=None, commit_messages_map=None):
171         self.feature_extractors = feature_extractors
172         self.cleanup_functions = cleanup_functions
173         self.rollback = rollback
174         self.rollback_when = rollback_when
175         self.commit_messages_map = commit_messages_map
176 
177     def fit(self, x, y=None):
178         return self
179 
180     def transform(self, bugs):
181         results = []
182 
183         for bug in bugs:
184             bug_id = bug['id']
185 
186             if self.rollback:
187                 bug = bug_snapshot.rollback(bug, self.rollback_when)
188 
189             data = {}
190 
191             for f in self.feature_extractors:
192                 res = f(bug)
193 
194                 if res is None:
195                     continue
196 
197                 if isinstance(res, list):
198                     for item in res:
199                         data[f.__class__.__name__ + '-' + item] = 'True'
200                     continue
201 
202                 if isinstance(res, bool):
203                     res = str(res)
204 
205                 data[f.__class__.__name__] = res
206 
207             # TODO: Try simply using all possible fields instead of extracting features manually.
208 
209             for cleanup_function in self.cleanup_functions:
210                 bug['summary'] = cleanup_function(bug['summary'])
211                 for c in bug['comments']:
212                     c['text'] = cleanup_function(c['text'])
213 
214             result = {
215                 'data': data,
216                 'title': bug['summary'],
217                 'first_comment': bug['comments'][0]['text'],
218                 'comments': ' '.join([c['text'] for c in bug['comments']]),
219             }
220 
221             if self.commit_messages_map is not None:
222                 result['commits'] = self.commit_messages_map[bug_id] if bug_id in self.commit_messages_map else ''
223 
224             results.append(result)
225 
226         return pd.DataFrame(results)
227
```
--- 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()

```

diff --git a/bugbug/bug_features.py b/bugbug/bug_features.py
--- a/bugbug/bug_features.py
+++ b/bugbug/bug_features.py
@@ -126,6 +126,11 @@
         return bug['component']
 
 
+class is_mozillian(object):
+    def __call__(self, bug):
+        return any(bug['creator_detail']['email'].endswith(domain) for domain in ['@mozilla.com', '@mozilla.org'])
+
+
 def cleanup_url(text):
     text = re.sub(r'http[s]?://(hg.mozilla|searchfox|dxr.mozilla)\S+', '__CODE_REFERENCE_URL__', text)
     return re.sub(r'http\S+', '__URL__', text)

{"golden_diff": "diff --git a/bugbug/bug_features.py b/bugbug/bug_features.py\n--- a/bugbug/bug_features.py\n+++ b/bugbug/bug_features.py\n@@ -126,6 +126,11 @@\n         return bug['component']\n \n \n+class is_mozillian(object):\n+    def __call__(self, bug):\n+        return any(bug['creator_detail']['email'].endswith(domain) for domain in ['@mozilla.com', '@mozilla.org'])\n+\n+\n def cleanup_url(text):\n     text = re.sub(r'http[s]?://(hg.mozilla|searchfox|dxr.mozilla)\\S+', '__CODE_REFERENCE_URL__', text)\n     return re.sub(r'http\\S+', '__URL__', text)\n", "issue": "'Is reporter a Mozillian' as a feature\nThe first implementation will simply check if an email contains \"@mozilla.com\" or \"@mozilla.org\".\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n# You can obtain one at http://mozilla.org/MPL/2.0/.\n\nimport re\n\nimport pandas as pd\nfrom sklearn.base import BaseEstimator\nfrom sklearn.base import TransformerMixin\n\nfrom bugbug import bug_snapshot\n\n\ndef field(bug, field):\n    if field in bug and bug[field] != '---':\n        return bug[field]\n\n    return None\n\n\nclass has_str(object):\n    def __call__(self, bug):\n        return field(bug, 'cf_has_str')\n\n\nclass has_regression_range(object):\n    def __call__(self, bug):\n        return field(bug, 'cf_has_regression_range')\n\n\nclass has_crash_signature(object):\n    def __call__(self, bug):\n        return 'cf_crash_signature' in bug and bug['cf_crash_signature'] != ''\n\n\nclass keywords(object):\n    def __init__(self, to_ignore=set()):\n        self.to_ignore = to_ignore\n\n    def __call__(self, bug):\n        keywords = []\n        subkeywords = []\n        for keyword in bug['keywords']:\n            if keyword in self.to_ignore:\n                continue\n\n            keywords.append(keyword)\n\n            if keyword.startswith('sec-'):\n                subkeywords.append('sec-')\n            elif keyword.startswith('csectype-'):\n                subkeywords.append('csectype-')\n        return keywords + subkeywords\n\n\nclass severity(object):\n    def __call__(self, bug):\n        return field(bug, 'severity')\n\n\nclass is_coverity_issue(object):\n    def __call__(self, bug):\n        return re.search('[CID ?[0-9]+]', bug['summary']) is not None or re.search('[CID ?[0-9]+]', bug['whiteboard']) is not None\n\n\nclass has_url(object):\n    def __call__(self, bug):\n        return bug['url'] != ''\n\n\nclass has_w3c_url(object):\n    def __call__(self, bug):\n        return 'w3c' in bug['url']\n\n\nclass has_github_url(object):\n    def __call__(self, bug):\n        return 'github' in bug['url']\n\n\nclass whiteboard(object):\n    def __call__(self, bug):\n        ret = []\n\n        # TODO: Add any [XXX:YYY] that appears in the whiteboard as [XXX: only\n\n        for elem in ['memshrink', '[ux]']:\n            if elem in bug['whiteboard'].lower():\n                ret.append(elem)\n\n        return ret\n\n\nclass patches(object):\n    def __call__(self, bug):\n        return sum(1 for a in bug['attachments'] if a['is_patch'] or a['content_type'] in ['text/x-review-board-request', 'text/x-phabricator-request'])\n\n\nclass landings(object):\n    def __call__(self, bug):\n        return sum(1 for c in bug['comments'] if '://hg.mozilla.org/' in c['text'])\n\n\nclass title(object):\n    def __call__(self, bug):\n        ret = []\n\n        keywords = [\n            'fail',\n        ]\n        for keyword in keywords:\n            if keyword in bug['summary'].lower():\n                ret.append(keyword)\n\n        return ret\n\n\nclass product(object):\n    def __call__(self, bug):\n        return bug['product']\n\n\nclass component(object):\n    def __call__(self, bug):\n        return bug['component']\n\n\ndef cleanup_url(text):\n    text = re.sub(r'http[s]?://(hg.mozilla|searchfox|dxr.mozilla)\\S+', '__CODE_REFERENCE_URL__', text)\n    return re.sub(r'http\\S+', '__URL__', text)\n\n\ndef cleanup_fileref(text):\n    return re.sub(r'\\w+\\.py\\b|\\w+\\.json\\b|\\w+\\.js\\b|\\w+\\.jsm\\b|\\w+\\.html\\b|\\w+\\.css\\b|\\w+\\.c\\b|\\w+\\.cpp\\b|\\w+\\.h\\b', '__FILE_REFERENCE__', text)\n\n\ndef cleanup_responses(text):\n    return re.sub('>[^\\n]+', ' ', text)\n\n\ndef cleanup_hex(text):\n    return re.sub(r'\\b0[xX][0-9a-fA-F]+\\b', '__HEX_NUMBER__', text)\n\n\ndef cleanup_dll(text):\n    return re.sub(r'\\w+\\.dll\\b', '__DLL_NAME__', text)\n\n\ndef cleanup_synonyms(text):\n    synonyms = [\n        ('safemode', ['safemode', 'safe mode']),\n        ('str', ['str', 'steps to reproduce', 'repro steps']),\n        ('uaf', ['uaf', 'use after free', 'use-after-free']),\n        ('asan', ['asan', 'address sanitizer', 'addresssanitizer']),\n        ('permafailure', ['permafailure', 'permafailing', 'permafail', 'perma failure', 'perma failing', 'perma fail', 'perma-failure', 'perma-failing', 'perma-fail']),\n    ]\n\n    for synonym_group, synonym_list in synonyms:\n        text = re.sub('|'.join(synonym_list), synonym_group, text, flags=re.IGNORECASE)\n\n    return text\n\n\ndef cleanup_crash(text):\n    return re.sub(r'bp-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{6}[0-9]{6}\\b', '__CRASH_STATS_LINK__', text)\n\n\nclass BugExtractor(BaseEstimator, TransformerMixin):\n    def __init__(self, feature_extractors, cleanup_functions, rollback=False, rollback_when=None, commit_messages_map=None):\n        self.feature_extractors = feature_extractors\n        self.cleanup_functions = cleanup_functions\n        self.rollback = rollback\n        self.rollback_when = rollback_when\n        self.commit_messages_map = commit_messages_map\n\n    def fit(self, x, y=None):\n        return self\n\n    def transform(self, bugs):\n        results = []\n\n        for bug in bugs:\n            bug_id = bug['id']\n\n            if self.rollback:\n                bug = bug_snapshot.rollback(bug, self.rollback_when)\n\n            data = {}\n\n            for f in self.feature_extractors:\n                res = f(bug)\n\n                if res is None:\n                    continue\n\n                if isinstance(res, list):\n                    for item in res:\n                        data[f.__class__.__name__ + '-' + item] = 'True'\n                    continue\n\n                if isinstance(res, bool):\n                    res = str(res)\n\n                data[f.__class__.__name__] = res\n\n            # TODO: Try simply using all possible fields instead of extracting features manually.\n\n            for cleanup_function in self.cleanup_functions:\n                bug['summary'] = cleanup_function(bug['summary'])\n                for c in bug['comments']:\n                    c['text'] = cleanup_function(c['text'])\n\n            result = {\n                'data': data,\n                'title': bug['summary'],\n                'first_comment': bug['comments'][0]['text'],\n                'comments': ' '.join([c['text'] for c in bug['comments']]),\n            }\n\n            if self.commit_messages_map is not None:\n                result['commits'] = self.commit_messages_map[bug_id] if bug_id in self.commit_messages_map else ''\n\n            results.append(result)\n\n        return pd.DataFrame(results)\n", "path": "bugbug/bug_features.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n# You can obtain one at http://mozilla.org/MPL/2.0/.\n\nimport re\n\nimport pandas as pd\nfrom sklearn.base import BaseEstimator\nfrom sklearn.base import TransformerMixin\n\nfrom bugbug import bug_snapshot\n\n\ndef field(bug, field):\n    if field in bug and bug[field] != '---':\n        return bug[field]\n\n    return None\n\n\nclass has_str(object):\n    def __call__(self, bug):\n        return field(bug, 'cf_has_str')\n\n\nclass has_regression_range(object):\n    def __call__(self, bug):\n        return field(bug, 'cf_has_regression_range')\n\n\nclass has_crash_signature(object):\n    def __call__(self, bug):\n        return 'cf_crash_signature' in bug and bug['cf_crash_signature'] != ''\n\n\nclass keywords(object):\n    def __init__(self, to_ignore=set()):\n        self.to_ignore = to_ignore\n\n    def __call__(self, bug):\n        keywords = []\n        subkeywords = []\n        for keyword in bug['keywords']:\n            if keyword in self.to_ignore:\n                continue\n\n            keywords.append(keyword)\n\n            if keyword.startswith('sec-'):\n                subkeywords.append('sec-')\n            elif keyword.startswith('csectype-'):\n                subkeywords.append('csectype-')\n        return keywords + subkeywords\n\n\nclass severity(object):\n    def __call__(self, bug):\n        return field(bug, 'severity')\n\n\nclass is_coverity_issue(object):\n    def __call__(self, bug):\n        return re.search('[CID ?[0-9]+]', bug['summary']) is not None or re.search('[CID ?[0-9]+]', bug['whiteboard']) is not None\n\n\nclass has_url(object):\n    def __call__(self, bug):\n        return bug['url'] != ''\n\n\nclass has_w3c_url(object):\n    def __call__(self, bug):\n        return 'w3c' in bug['url']\n\n\nclass has_github_url(object):\n    def __call__(self, bug):\n        return 'github' in bug['url']\n\n\nclass whiteboard(object):\n    def __call__(self, bug):\n        ret = []\n\n        # TODO: Add any [XXX:YYY] that appears in the whiteboard as [XXX: only\n\n        for elem in ['memshrink', '[ux]']:\n            if elem in bug['whiteboard'].lower():\n                ret.append(elem)\n\n        return ret\n\n\nclass patches(object):\n    def __call__(self, bug):\n        return sum(1 for a in bug['attachments'] if a['is_patch'] or a['content_type'] in ['text/x-review-board-request', 'text/x-phabricator-request'])\n\n\nclass landings(object):\n    def __call__(self, bug):\n        return sum(1 for c in bug['comments'] if '://hg.mozilla.org/' in c['text'])\n\n\nclass title(object):\n    def __call__(self, bug):\n        ret = []\n\n        keywords = [\n            'fail',\n        ]\n        for keyword in keywords:\n            if keyword in bug['summary'].lower():\n                ret.append(keyword)\n\n        return ret\n\n\nclass product(object):\n    def __call__(self, bug):\n        return bug['product']\n\n\nclass component(object):\n    def __call__(self, bug):\n        return bug['component']\n\n\nclass is_mozillian(object):\n    def __call__(self, bug):\n        return any(bug['creator_detail']['email'].endswith(domain) for domain in ['@mozilla.com', '@mozilla.org'])\n\n\ndef cleanup_url(text):\n    text = re.sub(r'http[s]?://(hg.mozilla|searchfox|dxr.mozilla)\\S+', '__CODE_REFERENCE_URL__', text)\n    return re.sub(r'http\\S+', '__URL__', text)\n\n\ndef cleanup_fileref(text):\n    return re.sub(r'\\w+\\.py\\b|\\w+\\.json\\b|\\w+\\.js\\b|\\w+\\.jsm\\b|\\w+\\.html\\b|\\w+\\.css\\b|\\w+\\.c\\b|\\w+\\.cpp\\b|\\w+\\.h\\b', '__FILE_REFERENCE__', text)\n\n\ndef cleanup_responses(text):\n    return re.sub('>[^\\n]+', ' ', text)\n\n\ndef cleanup_hex(text):\n    return re.sub(r'\\b0[xX][0-9a-fA-F]+\\b', '__HEX_NUMBER__', text)\n\n\ndef cleanup_dll(text):\n    return re.sub(r'\\w+\\.dll\\b', '__DLL_NAME__', text)\n\n\ndef cleanup_synonyms(text):\n    synonyms = [\n        ('safemode', ['safemode', 'safe mode']),\n        ('str', ['str', 'steps to reproduce', 'repro steps']),\n        ('uaf', ['uaf', 'use after free', 'use-after-free']),\n        ('asan', ['asan', 'address sanitizer', 'addresssanitizer']),\n        ('permafailure', ['permafailure', 'permafailing', 'permafail', 'perma failure', 'perma failing', 'perma fail', 'perma-failure', 'perma-failing', 'perma-fail']),\n    ]\n\n    for synonym_group, synonym_list in synonyms:\n        text = re.sub('|'.join(synonym_list), synonym_group, text, flags=re.IGNORECASE)\n\n    return text\n\n\ndef cleanup_crash(text):\n    return re.sub(r'bp-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{6}[0-9]{6}\\b', '__CRASH_STATS_LINK__', text)\n\n\nclass BugExtractor(BaseEstimator, TransformerMixin):\n    def __init__(self, feature_extractors, cleanup_functions, rollback=False, rollback_when=None, commit_messages_map=None):\n        self.feature_extractors = feature_extractors\n        self.cleanup_functions = cleanup_functions\n        self.rollback = rollback\n        self.rollback_when = rollback_when\n        self.commit_messages_map = commit_messages_map\n\n    def fit(self, x, y=None):\n        return self\n\n    def transform(self, bugs):\n        results = []\n\n        for bug in bugs:\n            bug_id = bug['id']\n\n            if self.rollback:\n                bug = bug_snapshot.rollback(bug, self.rollback_when)\n\n            data = {}\n\n            for f in self.feature_extractors:\n                res = f(bug)\n\n                if res is None:\n                    continue\n\n                if isinstance(res, list):\n                    for item in res:\n                        data[f.__class__.__name__ + '-' + item] = 'True'\n                    continue\n\n                if isinstance(res, bool):\n                    res = str(res)\n\n                data[f.__class__.__name__] = res\n\n            # TODO: Try simply using all possible fields instead of extracting features manually.\n\n            for cleanup_function in self.cleanup_functions:\n                bug['summary'] = cleanup_function(bug['summary'])\n                for c in bug['comments']:\n                    c['text'] = cleanup_function(c['text'])\n\n            result = {\n                'data': data,\n                'title': bug['summary'],\n                'first_comment': bug['comments'][0]['text'],\n                'comments': ' '.join([c['text'] for c in bug['comments']]),\n            }\n\n            if self.commit_messages_map is not None:\n                result['commits'] = self.commit_messages_map[bug_id] if bug_id in self.commit_messages_map else ''\n\n            results.append(result)\n\n        return pd.DataFrame(results)\n", "path": "bugbug/bug_features.py"}]}