We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
NH: legislators scrape is failing
State: NH

Legislator scraper needs some attention

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `openstates/nh/legislators.py`
Content:
```
1 import re
2 
3 from billy.scrape.legislators import LegislatorScraper, Legislator
4 from openstates.utils import LXMLMixin
5 
6 
7 class NHLegislatorScraper(LegislatorScraper, LXMLMixin):
8     jurisdiction = 'nh'
9     latest_only = True
10     members_url = 'http://www.gencourt.state.nh.us/downloads/Members.txt'
11 
12     chamber_map = {'H': 'lower', 'S': 'upper'}
13     party_map = {
14         'D': 'Democratic',
15         'R': 'Republican',
16         'I': 'Independent',
17         'L': 'Libertarian',
18     }
19 
20     def _get_photo(self, url, chamber):
21         """Attempts to find a portrait in the given legislator profile."""
22         doc = self.lxmlize(url)
23 
24         if chamber == 'upper':
25             src = doc.xpath('//div[@id="page_content"]//img[contains(@src, '
26                 '"images/senators") or contains(@src, "Senator")]/@src')
27         elif chamber == 'lower':
28             src = doc.xpath('//img[contains(@src, "images/memberpics")]/@src')
29 
30         if src and 'nophoto' not in src[0]:
31             photo_url = src[0]
32         else:
33             photo_url = ''
34 
35         return photo_url
36 
37     def _parse_legislator(self, row, chamber, term):
38         # Capture legislator vitals.
39         first_name = row['FirstName']
40         middle_name = row['MiddleName']
41         last_name = row['lastname']
42         full_name = '{} {} {}'.format(first_name, middle_name, last_name)
43         full_name = re.sub(r'[\s]{2,}', ' ', full_name)
44 
45         district = '{} {}'.format(row['county'], int(row['District'])).strip()
46         party = self.party_map[row['party']]
47         email = row['EMailAddress1']
48 
49         legislator = Legislator(term, chamber, district, full_name,
50                                 first_name=first_name, last_name=last_name,
51                                 middle_name=middle_name, party=party,
52                                 email=email)
53 
54         # Capture legislator office contact information.
55         district_address = '{}\n{}\n{}, {} {}'.format(row['street'],
56             row['address2'], row['city'], row['state'], row['zipcode']).strip()
57 
58         legislator.add_office('district', 'Home Address',
59                               address=district_address)
60 
61         # Retrieve legislator portrait.
62         #profile_url = None
63         #if chamber == 'upper':
64         #    profile_url = 'http://www.gencourt.state.nh.us/Senate/members/webpages/district{:02d}.aspx'.format(row['District'])
65         #elif chamber == 'lower':
66         #    profile_url = 'http://www.gencourt.state.nh.us/house/members/member.aspx?member={}'.format(row['employee_no'])
67 
68         #if profile_url:
69         #    legislator['photo_url'] = self._get_photo(profile_url, chamber)
70         #    legislator.add_source(profile_url)
71 
72         return legislator
73 
74     def _parse_members_txt(self):
75         lines = self.get(self.members_url).text.splitlines()
76 
77         header = lines[0].split('\t')
78 
79         for line in lines[1:]:
80             yield dict(zip(header, line.split('\t')))
81 
82     def scrape(self, chamber, term):
83         for row in self._parse_members_txt():
84             if self.chamber_map[row['LegislativeBody']] == chamber:
85                 leg = self._parse_legislator(row, chamber, term)
86                 leg.add_source(self.members_url)
87                 self.save_legislator(leg)
88
```
--- 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/openstates/nh/legislators.py b/openstates/nh/legislators.py
--- a/openstates/nh/legislators.py
+++ b/openstates/nh/legislators.py
@@ -38,13 +38,13 @@
         # Capture legislator vitals.
         first_name = row['FirstName']
         middle_name = row['MiddleName']
-        last_name = row['lastname']
+        last_name = row['LastName']
         full_name = '{} {} {}'.format(first_name, middle_name, last_name)
         full_name = re.sub(r'[\s]{2,}', ' ', full_name)
 
-        district = '{} {}'.format(row['county'], int(row['District'])).strip()
-        party = self.party_map[row['party']]
-        email = row['EMailAddress1']
+        district = '{} {}'.format(row['County'], int(row['District'])).strip()
+        party = self.party_map[row['party'].upper()]
+        email = row['WorkEmail']
 
         legislator = Legislator(term, chamber, district, full_name,
                                 first_name=first_name, last_name=last_name,
@@ -52,8 +52,8 @@
                                 email=email)
 
         # Capture legislator office contact information.
-        district_address = '{}\n{}\n{}, {} {}'.format(row['street'],
-            row['address2'], row['city'], row['state'], row['zipcode']).strip()
+        district_address = '{}\n{}\n{}, {} {}'.format(row['Address'],
+            row['address2'], row['city'], row['State'], row['Zipcode']).strip()
 
         legislator.add_office('district', 'Home Address',
                               address=district_address)

{"golden_diff": "diff --git a/openstates/nh/legislators.py b/openstates/nh/legislators.py\n--- a/openstates/nh/legislators.py\n+++ b/openstates/nh/legislators.py\n@@ -38,13 +38,13 @@\n         # Capture legislator vitals.\n         first_name = row['FirstName']\n         middle_name = row['MiddleName']\n-        last_name = row['lastname']\n+        last_name = row['LastName']\n         full_name = '{} {} {}'.format(first_name, middle_name, last_name)\n         full_name = re.sub(r'[\\s]{2,}', ' ', full_name)\n \n-        district = '{} {}'.format(row['county'], int(row['District'])).strip()\n-        party = self.party_map[row['party']]\n-        email = row['EMailAddress1']\n+        district = '{} {}'.format(row['County'], int(row['District'])).strip()\n+        party = self.party_map[row['party'].upper()]\n+        email = row['WorkEmail']\n \n         legislator = Legislator(term, chamber, district, full_name,\n                                 first_name=first_name, last_name=last_name,\n@@ -52,8 +52,8 @@\n                                 email=email)\n \n         # Capture legislator office contact information.\n-        district_address = '{}\\n{}\\n{}, {} {}'.format(row['street'],\n-            row['address2'], row['city'], row['state'], row['zipcode']).strip()\n+        district_address = '{}\\n{}\\n{}, {} {}'.format(row['Address'],\n+            row['address2'], row['city'], row['State'], row['Zipcode']).strip()\n \n         legislator.add_office('district', 'Home Address',\n                               address=district_address)\n", "issue": "NH: legislators scrape is failing\nState: NH\r\n\r\nLegislator scraper needs some attention\n", "before_files": [{"content": "import re\n\nfrom billy.scrape.legislators import LegislatorScraper, Legislator\nfrom openstates.utils import LXMLMixin\n\n\nclass NHLegislatorScraper(LegislatorScraper, LXMLMixin):\n    jurisdiction = 'nh'\n    latest_only = True\n    members_url = 'http://www.gencourt.state.nh.us/downloads/Members.txt'\n\n    chamber_map = {'H': 'lower', 'S': 'upper'}\n    party_map = {\n        'D': 'Democratic',\n        'R': 'Republican',\n        'I': 'Independent',\n        'L': 'Libertarian',\n    }\n\n    def _get_photo(self, url, chamber):\n        \"\"\"Attempts to find a portrait in the given legislator profile.\"\"\"\n        doc = self.lxmlize(url)\n\n        if chamber == 'upper':\n            src = doc.xpath('//div[@id=\"page_content\"]//img[contains(@src, '\n                '\"images/senators\") or contains(@src, \"Senator\")]/@src')\n        elif chamber == 'lower':\n            src = doc.xpath('//img[contains(@src, \"images/memberpics\")]/@src')\n\n        if src and 'nophoto' not in src[0]:\n            photo_url = src[0]\n        else:\n            photo_url = ''\n\n        return photo_url\n\n    def _parse_legislator(self, row, chamber, term):\n        # Capture legislator vitals.\n        first_name = row['FirstName']\n        middle_name = row['MiddleName']\n        last_name = row['lastname']\n        full_name = '{} {} {}'.format(first_name, middle_name, last_name)\n        full_name = re.sub(r'[\\s]{2,}', ' ', full_name)\n\n        district = '{} {}'.format(row['county'], int(row['District'])).strip()\n        party = self.party_map[row['party']]\n        email = row['EMailAddress1']\n\n        legislator = Legislator(term, chamber, district, full_name,\n                                first_name=first_name, last_name=last_name,\n                                middle_name=middle_name, party=party,\n                                email=email)\n\n        # Capture legislator office contact information.\n        district_address = '{}\\n{}\\n{}, {} {}'.format(row['street'],\n            row['address2'], row['city'], row['state'], row['zipcode']).strip()\n\n        legislator.add_office('district', 'Home Address',\n                              address=district_address)\n\n        # Retrieve legislator portrait.\n        #profile_url = None\n        #if chamber == 'upper':\n        #    profile_url = 'http://www.gencourt.state.nh.us/Senate/members/webpages/district{:02d}.aspx'.format(row['District'])\n        #elif chamber == 'lower':\n        #    profile_url = 'http://www.gencourt.state.nh.us/house/members/member.aspx?member={}'.format(row['employee_no'])\n\n        #if profile_url:\n        #    legislator['photo_url'] = self._get_photo(profile_url, chamber)\n        #    legislator.add_source(profile_url)\n\n        return legislator\n\n    def _parse_members_txt(self):\n        lines = self.get(self.members_url).text.splitlines()\n\n        header = lines[0].split('\\t')\n\n        for line in lines[1:]:\n            yield dict(zip(header, line.split('\\t')))\n\n    def scrape(self, chamber, term):\n        for row in self._parse_members_txt():\n            if self.chamber_map[row['LegislativeBody']] == chamber:\n                leg = self._parse_legislator(row, chamber, term)\n                leg.add_source(self.members_url)\n                self.save_legislator(leg)\n", "path": "openstates/nh/legislators.py"}], "after_files": [{"content": "import re\n\nfrom billy.scrape.legislators import LegislatorScraper, Legislator\nfrom openstates.utils import LXMLMixin\n\n\nclass NHLegislatorScraper(LegislatorScraper, LXMLMixin):\n    jurisdiction = 'nh'\n    latest_only = True\n    members_url = 'http://www.gencourt.state.nh.us/downloads/Members.txt'\n\n    chamber_map = {'H': 'lower', 'S': 'upper'}\n    party_map = {\n        'D': 'Democratic',\n        'R': 'Republican',\n        'I': 'Independent',\n        'L': 'Libertarian',\n    }\n\n    def _get_photo(self, url, chamber):\n        \"\"\"Attempts to find a portrait in the given legislator profile.\"\"\"\n        doc = self.lxmlize(url)\n\n        if chamber == 'upper':\n            src = doc.xpath('//div[@id=\"page_content\"]//img[contains(@src, '\n                '\"images/senators\") or contains(@src, \"Senator\")]/@src')\n        elif chamber == 'lower':\n            src = doc.xpath('//img[contains(@src, \"images/memberpics\")]/@src')\n\n        if src and 'nophoto' not in src[0]:\n            photo_url = src[0]\n        else:\n            photo_url = ''\n\n        return photo_url\n\n    def _parse_legislator(self, row, chamber, term):\n        # Capture legislator vitals.\n        first_name = row['FirstName']\n        middle_name = row['MiddleName']\n        last_name = row['LastName']\n        full_name = '{} {} {}'.format(first_name, middle_name, last_name)\n        full_name = re.sub(r'[\\s]{2,}', ' ', full_name)\n\n        district = '{} {}'.format(row['County'], int(row['District'])).strip()\n        party = self.party_map[row['party'].upper()]\n        email = row['WorkEmail']\n\n        legislator = Legislator(term, chamber, district, full_name,\n                                first_name=first_name, last_name=last_name,\n                                middle_name=middle_name, party=party,\n                                email=email)\n\n        # Capture legislator office contact information.\n        district_address = '{}\\n{}\\n{}, {} {}'.format(row['Address'],\n            row['address2'], row['city'], row['State'], row['Zipcode']).strip()\n\n        legislator.add_office('district', 'Home Address',\n                              address=district_address)\n\n        # Retrieve legislator portrait.\n        #profile_url = None\n        #if chamber == 'upper':\n        #    profile_url = 'http://www.gencourt.state.nh.us/Senate/members/webpages/district{:02d}.aspx'.format(row['District'])\n        #elif chamber == 'lower':\n        #    profile_url = 'http://www.gencourt.state.nh.us/house/members/member.aspx?member={}'.format(row['employee_no'])\n\n        #if profile_url:\n        #    legislator['photo_url'] = self._get_photo(profile_url, chamber)\n        #    legislator.add_source(profile_url)\n\n        return legislator\n\n    def _parse_members_txt(self):\n        lines = self.get(self.members_url).text.splitlines()\n\n        header = lines[0].split('\\t')\n\n        for line in lines[1:]:\n            yield dict(zip(header, line.split('\\t')))\n\n    def scrape(self, chamber, term):\n        for row in self._parse_members_txt():\n            if self.chamber_map[row['LegislativeBody']] == chamber:\n                leg = self._parse_legislator(row, chamber, term)\n                leg.add_source(self.members_url)\n                self.save_legislator(leg)\n", "path": "openstates/nh/legislators.py"}]}