prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Walmart Spider Error
  Something with the Walmart spider appears to be failing. When importing the geojson file from alltheplaces.xyz to qgis or geojson.io, there are a large number of locations missing in the western US.
  
  ![image](https://user-images.githubusercontent.com/13926434/47406283-1fa81c80-d71b-11e8-8126-5264e71e1525.png)
  
  
  </issue>
  <code>
  [start of locations/spiders/walmart.py]
  1 # -*- coding: utf-8 -*-
  2 import scrapy
  3 import json
  4 
  5 from locations.items import GeojsonPointItem
  6 
  7 
  8 class WalmartSpider(scrapy.Spider):
  9     name = "walmart"
  10     allowed_domains = ["walmart.com"]
  11     start_urls = (
  12         'https://www.walmart.com/sitemap_store_main.xml',
  13     )
  14 
  15     def store_hours(self, store_hours):
  16         if store_hours == 'Mo-Su':
  17             return u'24/7'
  18         elif store_hours is None:
  19             return None
  20         else:
  21             return store_hours
  22 
  23     def parse(self, response):
  24         response.selector.remove_namespaces()
  25         for u in response.xpath('//loc/text()').extract():
  26             if u.endswith('/details'):
  27                 yield scrapy.Request(u.strip(), callback=self.parse_store)
  28 
  29     def parse_store(self, response):
  30         addr = response.xpath('//div[@itemprop="address"]')[0]
  31         yield GeojsonPointItem(
  32             lat=response.xpath('//meta[@itemprop="latitude"]/@content').extract_first(),
  33             lon=response.xpath('//meta[@itemprop="longitude"]/@content').extract_first(),
  34             ref=response.url.split('/')[4],
  35             phone=response.xpath('//meta[@itemprop="telephone"]/@content').extract_first(),
  36             name=response.xpath('//meta[@itemprop="name"]/@content').extract_first(),
  37             opening_hours=self.store_hours(response.xpath('//meta[@itemprop="openingHours"]/@content').extract_first()),
  38             addr_full=addr.xpath('//span[@itemprop="streetAddress"]/text()').extract_first(),
  39             city=addr.xpath('//span[@itemprop="locality"]/text()').extract_first(),
  40             state=addr.xpath('//span[@itemprop="addressRegion"]/text()').extract_first(),
  41             postcode=addr.xpath('//span[@itemprop="postalCode"]/text()').extract_first(),
  42         )
  43
  [end of locations/spiders/walmart.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/locations/spiders/walmart.py b/locations/spiders/walmart.py
  --- a/locations/spiders/walmart.py
  +++ b/locations/spiders/walmart.py
  @@ -1,7 +1,9 @@
   # -*- coding: utf-8 -*-
   import scrapy
   import json
  +import re
   
  +from collections import defaultdict
   from locations.items import GeojsonPointItem
   
   
  @@ -11,14 +13,39 @@
       start_urls = (
           'https://www.walmart.com/sitemap_store_main.xml',
       )
  +    retries = defaultdict(int)
   
       def store_hours(self, store_hours):
  -        if store_hours == 'Mo-Su':
  +        if store_hours.get('operationalHours').get('open24Hours') is True:
               return u'24/7'
  -        elif store_hours is None:
  +        elif not store_hours.get('operationalHoursCombined'):
               return None
           else:
  -            return store_hours
  +            op_hours = store_hours.get('operationalHoursCombined')
  +            open_hours = []
  +            for op_hour in op_hours:
  +                if op_hour.get('dailyHours').get('closed') is True:
  +                    continue
  +
  +                if op_hour.get('dailyHours').get('openFullDay') is True:
  +                    start_hr = '00:00'
  +                    end_hr = '24:00'
  +                else:
  +                    start_hr = op_hour.get('dailyHours').get('startHr')
  +                    end_hr = op_hour.get('dailyHours').get('endHr')
  +
  +                start_day = op_hour.get('startDayName')
  +                end_day = op_hour.get('endDayName')
  +
  +                if end_day is None:
  +                    end_day = ''
  +
  +                hours = start_day+'-'+end_day+' '+start_hr+'-'+end_hr
  +                open_hours.append(hours)
  +
  +            hours_combined = '; '.join(open_hours)
  +
  +            return hours_combined
   
       def parse(self, response):
           response.selector.remove_namespaces()
  @@ -27,16 +54,30 @@
                   yield scrapy.Request(u.strip(), callback=self.parse_store)
   
       def parse_store(self, response):
  -        addr = response.xpath('//div[@itemprop="address"]')[0]
  +        script = response.xpath("//script[contains(.,'WML_REDUX_INITIAL_STATE')]").extract_first()
  +        # In rare cases will hit page before script tag loads with content
  +        if script is None:
  +            if self.retries.get(response.url, 0) <= 2:
  +                self.retries[response.url] += 1
  +                yield scrapy.Request(response.url, callback=self.parse_store)  # Try again
  +            else:
  +                raise Exception('Retried too many times')
  +
  +        script_content = re.search(r'window.__WML_REDUX_INITIAL_STATE__ = (.*);</script>', script,
  +                                   flags=re.IGNORECASE | re.DOTALL).group(1)
  +
  +        store_data = json.loads(script_content).get('store')
  +
           yield GeojsonPointItem(
  -            lat=response.xpath('//meta[@itemprop="latitude"]/@content').extract_first(),
  -            lon=response.xpath('//meta[@itemprop="longitude"]/@content').extract_first(),
  -            ref=response.url.split('/')[4],
  -            phone=response.xpath('//meta[@itemprop="telephone"]/@content').extract_first(),
  -            name=response.xpath('//meta[@itemprop="name"]/@content').extract_first(),
  -            opening_hours=self.store_hours(response.xpath('//meta[@itemprop="openingHours"]/@content').extract_first()),
  -            addr_full=addr.xpath('//span[@itemprop="streetAddress"]/text()').extract_first(),
  -            city=addr.xpath('//span[@itemprop="locality"]/text()').extract_first(),
  -            state=addr.xpath('//span[@itemprop="addressRegion"]/text()').extract_first(),
  -            postcode=addr.xpath('//span[@itemprop="postalCode"]/text()').extract_first(),
  +            lat=store_data.get('geoPoint').get('latitude'),
  +            lon=store_data.get('geoPoint').get('longitude'),
  +            ref=store_data.get('id'),
  +            phone=store_data.get('phone'),
  +            name=store_data.get('displayName'),
  +            opening_hours=self.store_hours(store_data),
  +            addr_full=store_data.get('address').get('streetAddress'),
  +            city=store_data.get('address').get('city'),
  +            state=store_data.get('address').get('state'),
  +            postcode=store_data.get('address').get('postalCode'),
  +            website=store_data.get('detailsPageURL'),
           )
  
verification_info: {"golden_diff": "diff --git a/locations/spiders/walmart.py b/locations/spiders/walmart.py\n--- a/locations/spiders/walmart.py\n+++ b/locations/spiders/walmart.py\n@@ -1,7 +1,9 @@\n # -*- coding: utf-8 -*-\n import scrapy\n import json\n+import re\n \n+from collections import defaultdict\n from locations.items import GeojsonPointItem\n \n \n@@ -11,14 +13,39 @@\n     start_urls = (\n         'https://www.walmart.com/sitemap_store_main.xml',\n     )\n+    retries = defaultdict(int)\n \n     def store_hours(self, store_hours):\n-        if store_hours == 'Mo-Su':\n+        if store_hours.get('operationalHours').get('open24Hours') is True:\n             return u'24/7'\n-        elif store_hours is None:\n+        elif not store_hours.get('operationalHoursCombined'):\n             return None\n         else:\n-            return store_hours\n+            op_hours = store_hours.get('operationalHoursCombined')\n+            open_hours = []\n+            for op_hour in op_hours:\n+                if op_hour.get('dailyHours').get('closed') is True:\n+                    continue\n+\n+                if op_hour.get('dailyHours').get('openFullDay') is True:\n+                    start_hr = '00:00'\n+                    end_hr = '24:00'\n+                else:\n+                    start_hr = op_hour.get('dailyHours').get('startHr')\n+                    end_hr = op_hour.get('dailyHours').get('endHr')\n+\n+                start_day = op_hour.get('startDayName')\n+                end_day = op_hour.get('endDayName')\n+\n+                if end_day is None:\n+                    end_day = ''\n+\n+                hours = start_day+'-'+end_day+' '+start_hr+'-'+end_hr\n+                open_hours.append(hours)\n+\n+            hours_combined = '; '.join(open_hours)\n+\n+            return hours_combined\n \n     def parse(self, response):\n         response.selector.remove_namespaces()\n@@ -27,16 +54,30 @@\n                 yield scrapy.Request(u.strip(), callback=self.parse_store)\n \n     def parse_store(self, response):\n-        addr = response.xpath('//div[@itemprop=\"address\"]')[0]\n+        script = response.xpath(\"//script[contains(.,'WML_REDUX_INITIAL_STATE')]\").extract_first()\n+        # In rare cases will hit page before script tag loads with content\n+        if script is None:\n+            if self.retries.get(response.url, 0) <= 2:\n+                self.retries[response.url] += 1\n+                yield scrapy.Request(response.url, callback=self.parse_store)  # Try again\n+            else:\n+                raise Exception('Retried too many times')\n+\n+        script_content = re.search(r'window.__WML_REDUX_INITIAL_STATE__ = (.*);</script>', script,\n+                                   flags=re.IGNORECASE | re.DOTALL).group(1)\n+\n+        store_data = json.loads(script_content).get('store')\n+\n         yield GeojsonPointItem(\n-            lat=response.xpath('//meta[@itemprop=\"latitude\"]/@content').extract_first(),\n-            lon=response.xpath('//meta[@itemprop=\"longitude\"]/@content').extract_first(),\n-            ref=response.url.split('/')[4],\n-            phone=response.xpath('//meta[@itemprop=\"telephone\"]/@content').extract_first(),\n-            name=response.xpath('//meta[@itemprop=\"name\"]/@content').extract_first(),\n-            opening_hours=self.store_hours(response.xpath('//meta[@itemprop=\"openingHours\"]/@content').extract_first()),\n-            addr_full=addr.xpath('//span[@itemprop=\"streetAddress\"]/text()').extract_first(),\n-            city=addr.xpath('//span[@itemprop=\"locality\"]/text()').extract_first(),\n-            state=addr.xpath('//span[@itemprop=\"addressRegion\"]/text()').extract_first(),\n-            postcode=addr.xpath('//span[@itemprop=\"postalCode\"]/text()').extract_first(),\n+            lat=store_data.get('geoPoint').get('latitude'),\n+            lon=store_data.get('geoPoint').get('longitude'),\n+            ref=store_data.get('id'),\n+            phone=store_data.get('phone'),\n+            name=store_data.get('displayName'),\n+            opening_hours=self.store_hours(store_data),\n+            addr_full=store_data.get('address').get('streetAddress'),\n+            city=store_data.get('address').get('city'),\n+            state=store_data.get('address').get('state'),\n+            postcode=store_data.get('address').get('postalCode'),\n+            website=store_data.get('detailsPageURL'),\n         )\n", "issue": "Walmart Spider Error\nSomething with the Walmart spider appears to be failing. When importing the geojson file from alltheplaces.xyz to qgis or geojson.io, there are a large number of locations missing in the western US.\r\n\r\n![image](https://user-images.githubusercontent.com/13926434/47406283-1fa81c80-d71b-11e8-8126-5264e71e1525.png)\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport scrapy\nimport json\n\nfrom locations.items import GeojsonPointItem\n\n\nclass WalmartSpider(scrapy.Spider):\n    name = \"walmart\"\n    allowed_domains = [\"walmart.com\"]\n    start_urls = (\n        'https://www.walmart.com/sitemap_store_main.xml',\n    )\n\n    def store_hours(self, store_hours):\n        if store_hours == 'Mo-Su':\n            return u'24/7'\n        elif store_hours is None:\n            return None\n        else:\n            return store_hours\n\n    def parse(self, response):\n        response.selector.remove_namespaces()\n        for u in response.xpath('//loc/text()').extract():\n            if u.endswith('/details'):\n                yield scrapy.Request(u.strip(), callback=self.parse_store)\n\n    def parse_store(self, response):\n        addr = response.xpath('//div[@itemprop=\"address\"]')[0]\n        yield GeojsonPointItem(\n            lat=response.xpath('//meta[@itemprop=\"latitude\"]/@content').extract_first(),\n            lon=response.xpath('//meta[@itemprop=\"longitude\"]/@content').extract_first(),\n            ref=response.url.split('/')[4],\n            phone=response.xpath('//meta[@itemprop=\"telephone\"]/@content').extract_first(),\n            name=response.xpath('//meta[@itemprop=\"name\"]/@content').extract_first(),\n            opening_hours=self.store_hours(response.xpath('//meta[@itemprop=\"openingHours\"]/@content').extract_first()),\n            addr_full=addr.xpath('//span[@itemprop=\"streetAddress\"]/text()').extract_first(),\n            city=addr.xpath('//span[@itemprop=\"locality\"]/text()').extract_first(),\n            state=addr.xpath('//span[@itemprop=\"addressRegion\"]/text()').extract_first(),\n            postcode=addr.xpath('//span[@itemprop=\"postalCode\"]/text()').extract_first(),\n        )\n", "path": "locations/spiders/walmart.py"}]}