prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  WV: subcommittees treated as full committees
  Hello,
  
  So, with WV, the subcommittees (e.g., Finance subcommittees A, B, C) are not identified as a subcommittee.
  
  I know WV is a [round C state](https://github.com/openstates/planning/issues/11), but I thought it was worth mentioning...if only for a "TODO later" note.
  
  Best,
  Alex
  
  </issue>
  <code>
  [start of openstates/wv/committees.py]
  1 import re
  2 
  3 from billy.scrape.committees import CommitteeScraper, Committee
  4 
  5 import lxml.html
  6 
  7 
  8 class WVCommitteeScraper(CommitteeScraper):
  9     jurisdiction = "wv"
  10 
  11     def scrape(self, chamber, term):
  12         getattr(self, 'scrape_' + chamber)()
  13 
  14     def scrape_lower(self):
  15         url = 'http://www.legis.state.wv.us/committees/house/main.cfm'
  16         html = self.get(url).text
  17         doc = lxml.html.fromstring(html)
  18         doc.make_links_absolute(url)
  19 
  20         xpath = '//a[contains(@href, "HouseCommittee")]'
  21         for link in doc.xpath(xpath):
  22             text = link.text_content().strip()
  23             if text == '-':
  24                 continue
  25             committee = self.scrape_lower_committee(link=link, name=text)
  26             committee.add_source(url)
  27             self.save_committee(committee)
  28 
  29         url = 'http://www.legis.state.wv.us/committees/interims/interims.cfm'
  30         html = self.get(url).text
  31         doc = lxml.html.fromstring(html)
  32         doc.make_links_absolute(url)
  33         xpath = '//a[contains(@href, "committee.cfm")]'
  34         for link in doc.xpath(xpath):
  35             text = link.text_content().strip()
  36             if text == '-':
  37                 continue
  38             committee = self.scrape_interim_committee(link=link, name=text)
  39             committee.add_source(url)
  40             self.save_committee(committee)
  41 
  42     def scrape_lower_committee(self, link, name):
  43         url = re.sub(r'\s+', '', link.attrib['href'])
  44         html = self.get(url).text
  45         doc = lxml.html.fromstring(html)
  46         doc.make_links_absolute(url)
  47 
  48         comm = Committee('lower', name)
  49         comm.add_source(url)
  50 
  51         xpath = '//a[contains(@href, "?member=")]'
  52         for link in doc.xpath(xpath):
  53             name = link.text_content().strip()
  54             name = re.sub(r'^Delegate\s+', '', name)
  55             role = link.getnext().text or 'member'
  56             comm.add_member(name, role.strip())
  57 
  58         return comm
  59 
  60     def scrape_interim_committee(self, link, name):
  61         url = re.sub(r'\s+', '', link.attrib['href'])
  62         html = self.get(url).text
  63         doc = lxml.html.fromstring(html)
  64         doc.make_links_absolute(url)
  65 
  66         comm = Committee('joint', name)
  67         comm.add_source(url)
  68 
  69         xpath = '//a[contains(@href, "?member=")]'
  70         for link in doc.xpath(xpath):
  71             name = link.text_content().strip()
  72             name = re.sub(r'^Delegate\s+', '', name)
  73             name = re.sub(r'^Senator\s+', '', name)
  74             role = link.getnext().text or 'member'
  75             comm.add_member(name, role.strip())
  76 
  77         return comm
  78 
  79     def scrape_upper(self):
  80         url = 'http://www.legis.state.wv.us/committees/senate/main.cfm'
  81         html = self.get(url).text
  82         doc = lxml.html.fromstring(html)
  83         doc.make_links_absolute(url)
  84 
  85         xpath = '//a[contains(@href, "SenateCommittee")]'
  86         for link in doc.xpath(xpath):
  87             text = link.text_content().strip()
  88             if text == '-':
  89                 continue
  90             committee = self.scrape_upper_committee(link=link, name=text)
  91             committee.add_source(url)
  92             self.save_committee(committee)
  93 
  94     def scrape_upper_committee(self, link, name):
  95         url = re.sub(r'\s+', '', link.attrib['href'])
  96         html = self.get(url).text
  97         doc = lxml.html.fromstring(html)
  98         doc.make_links_absolute(url)
  99 
  100         comm = Committee('upper', name)
  101         comm.add_source(url)
  102 
  103         xpath = '//a[contains(@href, "?member=")]'
  104         for link in doc.xpath(xpath):
  105             name = link.text_content().strip()
  106             name = re.sub(r'^Delegate\s+', '', name)
  107             role = link.getnext().text or 'member'
  108             comm.add_member(name, role.strip())
  109 
  110         return comm
  111
  [end of openstates/wv/committees.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/wv/committees.py b/openstates/wv/committees.py
  --- a/openstates/wv/committees.py
  +++ b/openstates/wv/committees.py
  @@ -8,6 +8,14 @@
   class WVCommitteeScraper(CommitteeScraper):
       jurisdiction = "wv"
   
  +    # Manually resolved links between subcommittees and parent committees.
  +    subcommittee_parent_map = {
  +        'Post Audits Subcommittee': 'Government and Finance',
  +        'Parks, Recreation and Natural Resources Subcommittee': \
  +            'Government and Finance',
  +        'Tax Reform Subcommittee A': 'Joint Tax Reform',
  +    }
  +
       def scrape(self, chamber, term):
           getattr(self, 'scrape_' + chamber)()
   
  @@ -63,7 +71,16 @@
           doc = lxml.html.fromstring(html)
           doc.make_links_absolute(url)
   
  -        comm = Committee('joint', name)
  +        if 'Subcommittee' in name:
  +            # Check whether the parent committee is manually defined first
  +            # before attempting to automatically resolve it.
  +            parent = WVCommitteeScraper.subcommittee_parent_map.get(name, None)
  +            if parent is None:
  +                parent = name.partition('Subcommittee')[0].strip()
  +
  +            comm = Committee('joint', parent, subcommittee=name)
  +        else:
  +            comm = Committee('joint', name)
           comm.add_source(url)
   
           xpath = '//a[contains(@href, "?member=")]'
  
verification_info: {"golden_diff": "diff --git a/openstates/wv/committees.py b/openstates/wv/committees.py\n--- a/openstates/wv/committees.py\n+++ b/openstates/wv/committees.py\n@@ -8,6 +8,14 @@\n class WVCommitteeScraper(CommitteeScraper):\n     jurisdiction = \"wv\"\n \n+    # Manually resolved links between subcommittees and parent committees.\n+    subcommittee_parent_map = {\n+        'Post Audits Subcommittee': 'Government and Finance',\n+        'Parks, Recreation and Natural Resources Subcommittee': \\\n+            'Government and Finance',\n+        'Tax Reform Subcommittee A': 'Joint Tax Reform',\n+    }\n+\n     def scrape(self, chamber, term):\n         getattr(self, 'scrape_' + chamber)()\n \n@@ -63,7 +71,16 @@\n         doc = lxml.html.fromstring(html)\n         doc.make_links_absolute(url)\n \n-        comm = Committee('joint', name)\n+        if 'Subcommittee' in name:\n+            # Check whether the parent committee is manually defined first\n+            # before attempting to automatically resolve it.\n+            parent = WVCommitteeScraper.subcommittee_parent_map.get(name, None)\n+            if parent is None:\n+                parent = name.partition('Subcommittee')[0].strip()\n+\n+            comm = Committee('joint', parent, subcommittee=name)\n+        else:\n+            comm = Committee('joint', name)\n         comm.add_source(url)\n \n         xpath = '//a[contains(@href, \"?member=\")]'\n", "issue": "WV: subcommittees treated as full committees\nHello,\r\n\r\nSo, with WV, the subcommittees (e.g., Finance subcommittees A, B, C) are not identified as a subcommittee.\r\n\r\nI know WV is a [round C state](https://github.com/openstates/planning/issues/11), but I thought it was worth mentioning...if only for a \"TODO later\" note.\r\n\r\nBest,\r\nAlex\n", "before_files": [{"content": "import re\n\nfrom billy.scrape.committees import CommitteeScraper, Committee\n\nimport lxml.html\n\n\nclass WVCommitteeScraper(CommitteeScraper):\n    jurisdiction = \"wv\"\n\n    def scrape(self, chamber, term):\n        getattr(self, 'scrape_' + chamber)()\n\n    def scrape_lower(self):\n        url = 'http://www.legis.state.wv.us/committees/house/main.cfm'\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n\n        xpath = '//a[contains(@href, \"HouseCommittee\")]'\n        for link in doc.xpath(xpath):\n            text = link.text_content().strip()\n            if text == '-':\n                continue\n            committee = self.scrape_lower_committee(link=link, name=text)\n            committee.add_source(url)\n            self.save_committee(committee)\n\n        url = 'http://www.legis.state.wv.us/committees/interims/interims.cfm'\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n        xpath = '//a[contains(@href, \"committee.cfm\")]'\n        for link in doc.xpath(xpath):\n            text = link.text_content().strip()\n            if text == '-':\n                continue\n            committee = self.scrape_interim_committee(link=link, name=text)\n            committee.add_source(url)\n            self.save_committee(committee)\n\n    def scrape_lower_committee(self, link, name):\n        url = re.sub(r'\\s+', '', link.attrib['href'])\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n\n        comm = Committee('lower', name)\n        comm.add_source(url)\n\n        xpath = '//a[contains(@href, \"?member=\")]'\n        for link in doc.xpath(xpath):\n            name = link.text_content().strip()\n            name = re.sub(r'^Delegate\\s+', '', name)\n            role = link.getnext().text or 'member'\n            comm.add_member(name, role.strip())\n\n        return comm\n\n    def scrape_interim_committee(self, link, name):\n        url = re.sub(r'\\s+', '', link.attrib['href'])\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n\n        comm = Committee('joint', name)\n        comm.add_source(url)\n\n        xpath = '//a[contains(@href, \"?member=\")]'\n        for link in doc.xpath(xpath):\n            name = link.text_content().strip()\n            name = re.sub(r'^Delegate\\s+', '', name)\n            name = re.sub(r'^Senator\\s+', '', name)\n            role = link.getnext().text or 'member'\n            comm.add_member(name, role.strip())\n\n        return comm\n\n    def scrape_upper(self):\n        url = 'http://www.legis.state.wv.us/committees/senate/main.cfm'\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n\n        xpath = '//a[contains(@href, \"SenateCommittee\")]'\n        for link in doc.xpath(xpath):\n            text = link.text_content().strip()\n            if text == '-':\n                continue\n            committee = self.scrape_upper_committee(link=link, name=text)\n            committee.add_source(url)\n            self.save_committee(committee)\n\n    def scrape_upper_committee(self, link, name):\n        url = re.sub(r'\\s+', '', link.attrib['href'])\n        html = self.get(url).text\n        doc = lxml.html.fromstring(html)\n        doc.make_links_absolute(url)\n\n        comm = Committee('upper', name)\n        comm.add_source(url)\n\n        xpath = '//a[contains(@href, \"?member=\")]'\n        for link in doc.xpath(xpath):\n            name = link.text_content().strip()\n            name = re.sub(r'^Delegate\\s+', '', name)\n            role = link.getnext().text or 'member'\n            comm.add_member(name, role.strip())\n\n        return comm\n", "path": "openstates/wv/committees.py"}]}