prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  AZ Legislator with the following id has an invalid phone number AZL000372
  State: AZ  (be sure to include in ticket title)
  
  This repository is for issues with state data, for feature requests, etc.
  please visit the contributor guide (see above message) to file the issue in the correct place.
  
  
  </issue>
  <code>
  [start of openstates/az/legislators.py]
  1 from billy.scrape import NoDataForPeriod
  2 from billy.scrape.legislators import LegislatorScraper, Legislator
  3 from lxml import html
  4 
  5 import re, datetime
  6 
  7 class AZLegislatorScraper(LegislatorScraper):
  8     jurisdiction = 'az'
  9     parties = {
  10         'R': 'Republican',
  11         'D': 'Democratic',
  12         'L': 'Libertarian',
  13         'I': 'Independent',
  14         'G': 'Green'
  15     }
  16 
  17     def get_party(self, abbr):
  18         return self.parties[abbr]
  19 
  20     def scrape(self, chamber, term):
  21         # TODO: old AZ scraper allowed old sessions, they seem to be gone?
  22         self.validate_term(term, latest_only=True)
  23 
  24         body = {'lower': 'H', 'upper': 'S'}[chamber]
  25         url = 'http://www.azleg.gov/MemberRoster/?body=' + body
  26         page = self.get(url).text
  27 
  28         # there is a bad comment closing tag on this page
  29         page = page.replace('--!>', '-->')
  30 
  31         root = html.fromstring(page)
  32 
  33         path = '//table//tr'
  34         roster = root.xpath(path)[1:]
  35         for row in roster:
  36             position = ''
  37             name, district, party, email, room, phone, = row.xpath('td')
  38 
  39             if email.attrib.get('class') == 'vacantmember':
  40                 continue  # Skip any vacant members.
  41 
  42             link = name.xpath('string(a/@href)')
  43             if len(name) == 1:
  44                 name = name.text_content().strip()
  45             else:
  46                 position = name.tail.strip()
  47                 name = name[0].text_content().strip()
  48             if '--' in name:
  49                 name = name.split('--')[0].strip()
  50 
  51             linkpage = self.get(link).text
  52             linkpage = linkpage.replace('--!>', '-->')
  53             linkroot = html.fromstring(linkpage)
  54             linkroot.make_links_absolute(link)
  55 
  56             photos = linkroot.xpath("//img[contains(@src, 'MemberPhoto')]")
  57 
  58             if len(photos) != 1:
  59                 self.warning('no photo on ' + link)
  60                 photo_url = ''
  61             else:
  62                 photo_url = photos[0].attrib['src']
  63 
  64             district = district.text_content()
  65             party = party.text_content().strip()
  66             email = email.text_content().strip()
  67 
  68             if email.startswith('Email: '):
  69                 email = email.replace('Email: ', '').lower() + '@azleg.gov'
  70             else:
  71                 email = ''
  72 
  73             party = self.get_party(party)
  74             room = room.text_content().strip()
  75             if chamber == 'lower':
  76                 address = "House of Representatives\n"
  77             else:
  78                 address = "Senate\n"
  79             address = address + "1700 West Washington\n Room " + room  \
  80                               + "\nPhoenix, AZ 85007"
  81 
  82             phone = phone.text_content().strip()
  83             if not phone.startswith('602'):
  84                 phone = "602-" + phone
  85 
  86             leg = Legislator(term, chamber, district, full_name=name,
  87                                 party=party, url=link,
  88                                 photo_url=photo_url)
  89 
  90             leg.add_office('capitol', 'Capitol Office', address=address,
  91                            phone=phone, email=email)
  92 
  93             if position:
  94                 leg.add_role( position, term, chamber=chamber,
  95                              district=district, party=party)
  96 
  97             leg.add_source(url)
  98 
  99             #Probably just get this from the committee scraper
  100             #self.scrape_member_page(link, session, chamber, leg)
  101             self.save_legislator(leg)
  102 
  103     def scrape_member_page(self, url, session, chamber, leg):
  104         html = self.get(url).text
  105         root = html.fromstring(html)
  106         #get the committee membership
  107         c = root.xpath('//td/div/strong[contains(text(), "Committee")]')
  108         for row in c.xpath('ancestor::table[1]')[1:]:
  109             name = row[0].text_content().strip()
  110             role = row[1].text_content().strip()
  111             leg.add_role(role, session, chamber=chamber, committee=name)
  112 
  113         leg.add_source(url)
  114
  [end of openstates/az/legislators.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/openstates/az/legislators.py b/openstates/az/legislators.py
  --- a/openstates/az/legislators.py
  +++ b/openstates/az/legislators.py
  @@ -1,8 +1,7 @@
  -from billy.scrape import NoDataForPeriod
   from billy.scrape.legislators import LegislatorScraper, Legislator
   from lxml import html
  +import re
   
  -import re, datetime
   
   class AZLegislatorScraper(LegislatorScraper):
       jurisdiction = 'az'
  @@ -80,30 +79,30 @@
                                 + "\nPhoenix, AZ 85007"
   
               phone = phone.text_content().strip()
  -            if not phone.startswith('602'):
  +            if '602' not in re.findall(r'(\d+)', phone):
                   phone = "602-" + phone
   
               leg = Legislator(term, chamber, district, full_name=name,
  -                                party=party, url=link,
  -                                photo_url=photo_url)
  +                             party=party, url=link,
  +                             photo_url=photo_url)
   
               leg.add_office('capitol', 'Capitol Office', address=address,
                              phone=phone, email=email)
   
               if position:
  -                leg.add_role( position, term, chamber=chamber,
  +                leg.add_role(position, term, chamber=chamber,
                                district=district, party=party)
   
               leg.add_source(url)
   
  -            #Probably just get this from the committee scraper
  -            #self.scrape_member_page(link, session, chamber, leg)
  +            # Probably just get this from the committee scraper
  +            # self.scrape_member_page(link, session, chamber, leg)
               self.save_legislator(leg)
   
       def scrape_member_page(self, url, session, chamber, leg):
           html = self.get(url).text
           root = html.fromstring(html)
  -        #get the committee membership
  +        # get the committee membership
           c = root.xpath('//td/div/strong[contains(text(), "Committee")]')
           for row in c.xpath('ancestor::table[1]')[1:]:
               name = row[0].text_content().strip()
  
verification_info: {"golden_diff": "diff --git a/openstates/az/legislators.py b/openstates/az/legislators.py\n--- a/openstates/az/legislators.py\n+++ b/openstates/az/legislators.py\n@@ -1,8 +1,7 @@\n-from billy.scrape import NoDataForPeriod\n from billy.scrape.legislators import LegislatorScraper, Legislator\n from lxml import html\n+import re\n \n-import re, datetime\n \n class AZLegislatorScraper(LegislatorScraper):\n     jurisdiction = 'az'\n@@ -80,30 +79,30 @@\n                               + \"\\nPhoenix, AZ 85007\"\n \n             phone = phone.text_content().strip()\n-            if not phone.startswith('602'):\n+            if '602' not in re.findall(r'(\\d+)', phone):\n                 phone = \"602-\" + phone\n \n             leg = Legislator(term, chamber, district, full_name=name,\n-                                party=party, url=link,\n-                                photo_url=photo_url)\n+                             party=party, url=link,\n+                             photo_url=photo_url)\n \n             leg.add_office('capitol', 'Capitol Office', address=address,\n                            phone=phone, email=email)\n \n             if position:\n-                leg.add_role( position, term, chamber=chamber,\n+                leg.add_role(position, term, chamber=chamber,\n                              district=district, party=party)\n \n             leg.add_source(url)\n \n-            #Probably just get this from the committee scraper\n-            #self.scrape_member_page(link, session, chamber, leg)\n+            # Probably just get this from the committee scraper\n+            # self.scrape_member_page(link, session, chamber, leg)\n             self.save_legislator(leg)\n \n     def scrape_member_page(self, url, session, chamber, leg):\n         html = self.get(url).text\n         root = html.fromstring(html)\n-        #get the committee membership\n+        # get the committee membership\n         c = root.xpath('//td/div/strong[contains(text(), \"Committee\")]')\n         for row in c.xpath('ancestor::table[1]')[1:]:\n             name = row[0].text_content().strip()\n", "issue": "AZ Legislator with the following id has an invalid phone number AZL000372\nState: AZ  (be sure to include in ticket title)\r\n\r\nThis repository is for issues with state data, for feature requests, etc.\r\nplease visit the contributor guide (see above message) to file the issue in the correct place.\r\n\n", "before_files": [{"content": "from billy.scrape import NoDataForPeriod\nfrom billy.scrape.legislators import LegislatorScraper, Legislator\nfrom lxml import html\n\nimport re, datetime\n\nclass AZLegislatorScraper(LegislatorScraper):\n    jurisdiction = 'az'\n    parties = {\n        'R': 'Republican',\n        'D': 'Democratic',\n        'L': 'Libertarian',\n        'I': 'Independent',\n        'G': 'Green'\n    }\n\n    def get_party(self, abbr):\n        return self.parties[abbr]\n\n    def scrape(self, chamber, term):\n        # TODO: old AZ scraper allowed old sessions, they seem to be gone?\n        self.validate_term(term, latest_only=True)\n\n        body = {'lower': 'H', 'upper': 'S'}[chamber]\n        url = 'http://www.azleg.gov/MemberRoster/?body=' + body\n        page = self.get(url).text\n\n        # there is a bad comment closing tag on this page\n        page = page.replace('--!>', '-->')\n\n        root = html.fromstring(page)\n\n        path = '//table//tr'\n        roster = root.xpath(path)[1:]\n        for row in roster:\n            position = ''\n            name, district, party, email, room, phone, = row.xpath('td')\n\n            if email.attrib.get('class') == 'vacantmember':\n                continue  # Skip any vacant members.\n\n            link = name.xpath('string(a/@href)')\n            if len(name) == 1:\n                name = name.text_content().strip()\n            else:\n                position = name.tail.strip()\n                name = name[0].text_content().strip()\n            if '--' in name:\n                name = name.split('--')[0].strip()\n\n            linkpage = self.get(link).text\n            linkpage = linkpage.replace('--!>', '-->')\n            linkroot = html.fromstring(linkpage)\n            linkroot.make_links_absolute(link)\n\n            photos = linkroot.xpath(\"//img[contains(@src, 'MemberPhoto')]\")\n\n            if len(photos) != 1:\n                self.warning('no photo on ' + link)\n                photo_url = ''\n            else:\n                photo_url = photos[0].attrib['src']\n\n            district = district.text_content()\n            party = party.text_content().strip()\n            email = email.text_content().strip()\n\n            if email.startswith('Email: '):\n                email = email.replace('Email: ', '').lower() + '@azleg.gov'\n            else:\n                email = ''\n\n            party = self.get_party(party)\n            room = room.text_content().strip()\n            if chamber == 'lower':\n                address = \"House of Representatives\\n\"\n            else:\n                address = \"Senate\\n\"\n            address = address + \"1700 West Washington\\n Room \" + room  \\\n                              + \"\\nPhoenix, AZ 85007\"\n\n            phone = phone.text_content().strip()\n            if not phone.startswith('602'):\n                phone = \"602-\" + phone\n\n            leg = Legislator(term, chamber, district, full_name=name,\n                                party=party, url=link,\n                                photo_url=photo_url)\n\n            leg.add_office('capitol', 'Capitol Office', address=address,\n                           phone=phone, email=email)\n\n            if position:\n                leg.add_role( position, term, chamber=chamber,\n                             district=district, party=party)\n\n            leg.add_source(url)\n\n            #Probably just get this from the committee scraper\n            #self.scrape_member_page(link, session, chamber, leg)\n            self.save_legislator(leg)\n\n    def scrape_member_page(self, url, session, chamber, leg):\n        html = self.get(url).text\n        root = html.fromstring(html)\n        #get the committee membership\n        c = root.xpath('//td/div/strong[contains(text(), \"Committee\")]')\n        for row in c.xpath('ancestor::table[1]')[1:]:\n            name = row[0].text_content().strip()\n            role = row[1].text_content().strip()\n            leg.add_role(role, session, chamber=chamber, committee=name)\n\n        leg.add_source(url)\n", "path": "openstates/az/legislators.py"}]}