internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: alltheplaces/alltheplaces

Issue:
County Market
http://www.mycountymarket.com/shop/store-locator/


Discussion:

Resolving patch:
diff --git a/locations/spiders/county_market.py b/locations/spiders/county_market.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/county_market.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+import scrapy
+import json
+import re
+
+from locations.items import GeojsonPointItem
+
+
+SIEVE = ('View on Map', 'Make My Preferred Store!')
+DAYS = r'M|Tue|Wed|Thu|Sat|Sun|Fri'
+AM_PM = r'am|pm|a.m.|p.m.|a|p'
+
+
+class MyCountyMarketSpider(scrapy.Spider):
+    name = "county_market"
+    allowed_domains = ["www.mycountymarket.com", ]
+
+    start_urls = (
+        'http://www.mycountymarket.com/shop/store-locator/',
+    )
+
+    def parse_hours(self, hours):
+        if re.search(r'24 hours', hours.lower()):
+            return '24/7'
+        elif not re.search(DAYS, hours):
+            hours = hours.replace(' ', '').replace('to','-').replace('Midnight', '00:00')
+            return 'Mo-Su {}'.format(re.sub(AM_PM, ':00', hours))
+
+    def process_store(self, store):
+        opening_hours, phone = ('','')
+        data = store.xpath(
+            '//div[@class="col-lg-4"]/div/*[not(self::h2 or self::strong)]//text()').extract()
+        normalize_data = [val for val in [info.strip()
+                                          for info in data] if val]
+        final_data = [clean for clean in normalize_data if clean not in SIEVE]
+        city, state_zip = final_data[2].split(',')
+        state, pcode = state_zip.strip().split()
+        if 'Phone Number' in final_data:
+            phone = final_data[final_data.index('Phone Number')+1]
+        if 'Store Hours' in final_data:
+            opening_hours = self.parse_hours(final_data[final_data.index('Store Hours')+1:][0])
+
+        props = {
+            'addr_full': final_data[1],
+            'ref': store.url,
+            'city': city,
+            'postcode': pcode,
+            'state': state,
+            'website': store.url,
+            'opening_hours': opening_hours,
+            'phone': phone,
+        }
+
+        yield GeojsonPointItem(**props)
+
+    def parse(self, response):
+
+        stores = response.xpath(
+            '//div[@style="padding:5px;"]/a/@href').extract()
+        for store in stores:
+            yield scrapy.Request(
+                url=response.urljoin(store),
+                callback=self.process_store
+            )


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Caribou Coffee
https://locations.cariboucoffee.com/site-map


Discussion:

Resolving patch:
diff --git a/locations/spiders/caribou_coffee.py b/locations/spiders/caribou_coffee.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/caribou_coffee.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+import scrapy
+import json
+import re
+
+from locations.items import GeojsonPointItem
+
+NUMBER_DAY = {
+    '1': 'Mo',
+    '2': 'Tu',
+    '3': 'We',
+    '4': 'Th',
+    '5': 'Fr',
+    '6': 'Sa',
+    '7': 'Su'
+}
+
+
+class CaribouCoffeeSpider(scrapy.Spider):
+
+    name = "caribou_coffee"
+    allowed_domains = ["momentfeed-prod.apigee.net", ]
+
+    start_urls = (
+        'https://momentfeed-prod.apigee.net/api/llp.json?auth_token=CVTQBSJXYGFVUDEY&sitemap=true',
+    )
+    download_delay = 0.2
+
+    def normalize_hours(self, hours):
+
+        reversed_hours = {}
+        if not hours:
+            return ''
+        else:
+            days = [day for day in hours.split(';') if day]
+            for day in days:
+                day, from_hr, to_hr = day.split(',')
+
+                short_day = NUMBER_DAY[day]
+                from_hour = '{}:{}'.format(from_hr[:2], from_hr[2:])
+                to_hour = '{}:{}'.format(to_hr[:2], to_hr[2:])
+                epoch = '{}-{}'.format(from_hour, to_hour)
+
+                reversed_hours.setdefault(epoch, [])
+                reversed_hours[epoch].append(short_day)
+
+            if len(reversed_hours) == 1 and list(reversed_hours)[0] == '00:00-24:00':
+                return '24/7'
+
+            opening_hours = []
+
+            for key, value in reversed_hours.items():
+                if len(value) == 1:
+                    opening_hours.append('{} {}'.format(value[0], key))
+                else:
+                    opening_hours.append(
+                        '{}-{} {}'.format(value[0], value[-1], key))
+
+            return ";".join(opening_hours)
+
+    def parse(self, response):
+
+        stores = json.loads(response.body_as_unicode())
+
+        for store in stores:
+            opening_hours = ''
+            if store.get('store_info', '').get('store_hours', ''):
+                opening_hours = self.normalize_hours(
+                    store['store_info']['store_hours'])
+
+            props = {
+                'ref': store['store_info']['corporate_id'],
+                'addr_full': store['store_info']['address'],
+                'postcode': store['store_info']['postcode'],
+                'state': store['store_info']['region'],
+                'website': store['store_info']['website'],
+                'city': store['store_info']['locality'],
+                'phone': store['store_info']['phone'],
+                'lat': store['store_info']['latitude'],
+                'lon': store['store_info']['longitude'],
+                'opening_hours': opening_hours
+            }
+
+            yield GeojsonPointItem(**props)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Sainsbury's
Sainsbury's is a supermarket chain in the UK.

https://stores.sainsburys.co.uk/



Discussion:

Resolving patch:
diff --git a/locations/spiders/sainsburys.py b/locations/spiders/sainsburys.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/sainsburys.py
@@ -0,0 +1,56 @@
+import json
+import re
+import scrapy
+from locations.items import GeojsonPointItem
+DAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
+
+class SainsburysSpider(scrapy.Spider):
+    name = "sainsburys"
+    allowed_domains = ["stores.sainsburys.co.uk"]
+    state = True
+    def start_requests(self):
+        headers = {
+            'Accept-Language': 'en-US,en;q=0.9',
+            'Origin': 'https://www.kfc.com',
+            'Accept-Encoding': 'gzip, deflate',
+            'Accept': 'text/javascript, text/html, application/xml, text/xml, */*',
+            'Referer': 'http://locator.safeway.com/sto…edirection=no&mylocation=2706',
+            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
+            'X-Requested-With': 'XMLHttpRequest',
+        }
+
+        for page in range(1000):
+            if(self.state==False):
+                break
+            else:
+                url = 'https://stores.sainsburys.co.uk/api/v1/stores/?fields=slfe-list-2.21&api_client_id=slfe&lat=54.652247&lon=-2.219954&limit=25000000&store_type=main%2Clocal&sort=by_distance&within=1500000&page='+str(page)
+                yield scrapy.Request(
+                    url=url,
+                    callback=self.parse
+                )
+
+    def parse(self, response):
+        data = json.loads(response.body_as_unicode())
+
+        if(len(data['results'])==0):
+            self.state = False
+        else:
+            for store in data['results']:
+                open_hours = store['opening_times']
+                clean_hours = ''
+                for idx, time in enumerate(open_hours):
+                    clean_hours = clean_hours + DAYS[time['day']]+' '+time['start_time']+'-'+time['end_time']+' ; '
+
+                properties = {
+                    "ref": store['code'],
+                    "name": store['name'] ,
+                    "opening_hours": clean_hours,
+                    "website": 'https://stores.sainsburys.co.uk/%s/%s'%(store['code'] , store['other_name'].lower().replace(' ','-')),
+                    "addr_full": store['contact']['address1'],
+                    "city": store['contact']['city'],
+                    "postcode": store['contact']['post_code'],
+                    "country": 'United Kingdom',
+                    "lon": float( store['location']['lon']),
+                    "lat": float(store['location']['lat']),
+                }
+                yield GeojsonPointItem(**properties)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Bob's Burgers & Brew
http://www.bobsburgersandbrew.com/content/locations/locations


Discussion:
Plain HTML.
No progress for 6 days, re-opening this for others.
working on this

Resolving patch:
diff --git a/locations/spiders/bobs_burgers.py b/locations/spiders/bobs_burgers.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/bobs_burgers.py
@@ -0,0 +1,55 @@
+import scrapy
+from locations.items import GeojsonPointItem
+
+regex_street = r"^(\s?\d{1,5}\s[a-zA-Z]+\.?\s?\#?\d{0,5}[a-zA-Z]{0,10}" \
+               r"\.?\s?\#?\d{0,5}[a-zA-Z]{0,10}\.?\s?\#?\d{0,5}[a-zA-Z]{0,10})"
+regex_cty_st_zip = r"^(\s?[a-zA-z]+\s?[a-zA-z]{0,10},\sWA\.?\s\d{5})"
+regex_phone = r"^\s?\d{3}\.\d{3}\.\d{4}"
+regex_name = r"^(\s?[a-zA-z]+/?\s?[a-zA-z]{0,10}\s?Bob's)"
+
+
+class BobsSpider(scrapy.Spider):
+    name = 'bobs'
+    allowed_domains = ['www.bobsburgersandbrew.com']
+    start_urls = ['https://www.bobsburgersandbrew.com/content/locations/locations']
+
+    def parse(self, response):
+
+        names = response.xpath(
+            '//td[contains(@style,"300px") and contains('
+            '., "MAP")]/descendant-or-self::*/text()').re(regex_name)
+
+        streets = response.xpath(
+            '//td[contains(@style,"300px") and contains('
+            '., "MAP")]/descendant-or-self::*/text()').re(regex_street)
+
+        phones = response.xpath('//td[contains(@style,"300px") and contains('
+                                '., "MAP")]/descendant-or-self::*/text()').re(
+                                regex_phone)
+
+        cities = response.xpath(
+            '//td[contains(@style,"300px") and contains('
+            '., "MAP")]/descendant-or-self::*/text()').re(
+            regex_cty_st_zip)
+
+        stores = response.xpath(
+            '//td[contains(@style,"300px") and contains(., "MAP")]')
+        for i in range(len(stores)):
+            name = names[i].strip('\xa0').strip()
+            street = streets[i].strip()
+            city = cities[i].split(',')[0].strip()
+            cities[i] = cities[i].replace('WA.', 'WA ').strip()
+            postcode = cities[i].split('WA ')[1].strip()
+            addr_full = "{} {}, WA {}".format(street, city, postcode).strip()
+            phone = phones[i].replace('.', ' ').strip()
+
+            yield GeojsonPointItem(
+                ref=name,
+                name=name,
+                street=street,
+                city=city,
+                state='WA',
+                postcode=postcode,
+                addr_full=addr_full,
+                phone=phone
+            )


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Jumbo (Argentina)
Supermarket chain, also owned by Cencosud.

Webpage is https://www.jumbo.com.ar/Login/Sucursales.aspx but the website code is almost identical as [Disco](#90). Branch list can be retrieved as JSON in the same way:
```curl -H "Content-Type: application/json" -d "{}" https://www.jumbo.com.ar/Login/PreHomeService.aspx/TraerLocales```


Discussion:
Removing the assignee on this because there's been no update for 9 days.
working on this

Resolving patch:
diff --git a/locations/spiders/jumbo_ar.py b/locations/spiders/jumbo_ar.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/jumbo_ar.py
@@ -0,0 +1,39 @@
+import json
+import scrapy
+from locations.items import GeojsonPointItem
+
+class JumboArgentinaSpider(scrapy.Spider):
+    name = "jumbo_argentina"
+    allowed_domains = ["www.jumbo.com.ar"]
+
+    def start_requests(self):
+        url = 'https://www.jumbo.com.ar/Login/PreHomeService.aspx/TraerLocales'
+        headers={
+                    'Content-Type': 'application/json',
+                }
+        form_data = {}
+
+        yield scrapy.http.FormRequest(
+            url=url, method='POST', formdata=form_data,
+            headers=headers, callback=self.parse
+        )
+
+    def parse(self, response):
+        result = response.body_as_unicode().replace('\\', '')
+        result = result[:5] + result[6:-2] + result[-1:]
+        data = json.loads(result)
+        ref = 0
+        for store in data['d']['Locales']:
+            properties = {
+                'ref': ref,
+                'name': store['Local']['Nombre'].strip(),
+                'addr_full': store['Local']['Direccion'].strip(),
+                'city': store['Local']['Localidad'].strip(),
+                'state': store['Local']['Provincia'].strip(),
+                'postcode': store['Local']['CodigoPostal'].strip(),
+                'lat': float(store['Local']['Latitud'].strip()),
+                'lon': float(store['Local']['Longitud'].strip()),
+                'phone': store['Local']['Telefono'].strip(),
+            }
+            ref += 1
+            yield GeojsonPointItem(**properties)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Morrisons
Morrisons (apparently without the apostrophe) is a supermarket chain in the UK.

https://my.morrisons.com/storefinder/list/a



Discussion:

Resolving patch:
diff --git a/locations/spiders/morrisons.py b/locations/spiders/morrisons.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/morrisons.py
@@ -0,0 +1,70 @@
+import scrapy
+import re
+import json
+from locations.items import GeojsonPointItem
+
+DAYS = {
+    'mon': 'Mo',
+    'tue': 'Tu',
+    'wed': 'We',
+    'fri': 'Fr',
+    'thu': 'Th',
+    'sat': 'Sa',
+    'sun': 'Su',
+}
+
+
+class MorrisonsSpider(scrapy.Spider):
+
+    name = "morrisons"
+    allowed_domains = ["my.morrisons.com" ,"api.morrisons.com"]
+    download_delay = 0.5
+    start_urls = (
+        'https://my.morrisons.com/storefinder/list/a',
+    )
+
+    def store_hours(self, store_hours):
+        clean_time = ''
+        for key, value in store_hours.items():
+            if ('open' in value and 'close' in value):
+                if re.search('[0-9]{2}:[0-9]{2}:[0-9]{2}', value['open']) and re.search('[0-9]{2}:[0-9]{2}:[0-9]{2}', value['close']):
+                    clean_time = clean_time + DAYS[key] + ' ' + value['open'][0:5] + '-' + \
+                                 value['close'][0:5] + ';'
+                else:
+                    clean_time = clean_time + DAYS[key] + ' ' + 'Closed' + ';'
+
+        return clean_time
+
+    def parse_stores(self, response):
+        data = json.loads(response.body_as_unicode())
+        properties = {
+            'addr_full': data['address']['addressLine1']+" "+data['address']['addressLine2'],
+            'phone':data['telephone'] ,
+            'city': data['address']['city'],
+            'state': '',
+            'postcode': data['address']['postcode'],
+            'ref': data['name'],
+            'name': data['storeName'],
+            'country':data['address']['country'],
+            'website': 'https://my.morrisons.com/storefinder/'+str(data['name']),
+            'lat': data['location']['latitude'],
+            'lon':  data['location']['longitude'],
+        }
+
+        hours = self.store_hours(data['openingTimes'])
+        if hours:
+            properties['opening_hours'] = hours
+
+        yield GeojsonPointItem(**properties)
+
+    def parse_alpha(self, response):
+        alpha_urls = response.xpath('//div[@class="col-md-4 col-sm-6"]/a/@href').extract()
+        for path in alpha_urls:
+            id = re.findall(r"[0-9]+$" , path)[0]
+            url = 'https://api.morrisons.com/location/v2//stores/%s?apikey=nIqSiqIFeSeaQEomK5F0PHKfyNKKVVvD&include=departments,services,linkedStores'%(id)
+            yield scrapy.Request(response.urljoin(url), callback=self.parse_stores)
+
+    def parse(self, response):
+        urls = response.xpath('//div[@class="azWrapper"]/ul/li/a/@href').extract()
+        for path in urls:
+            yield scrapy.Request(response.urljoin(path), callback=self.parse_alpha)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
John Lewis
John Lewis is a department store chain in the UK.

https://www.johnlewis.com/our-shops


Discussion:

Resolving patch:
diff --git a/locations/spiders/johnlewis.py b/locations/spiders/johnlewis.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/johnlewis.py
@@ -0,0 +1,51 @@
+import scrapy
+import re
+from locations.items import GeojsonPointItem
+
+
+class JohnLewisSpider(scrapy.Spider):
+
+    name = "johnlewis"
+    allowed_domains = ["www.johnlewis.com"]
+    download_delay = 0.5
+    start_urls = (
+        'https://www.johnlewis.com/our-shops',
+    )
+
+    def parse_stores(self, response):
+        location = re.findall(r"[;?]ll=[^(&)]+", response.body_as_unicode())
+        addr_full = response.xpath('//div[@class="cq-shop-info"]/p[1]/text()|//div[@id="cq-shop-info"]/p[1]/text()|//div[@id="cq-full-width"]/div[@class="cq-content"]/div/p[@class="shop-address"]/text()').extract()
+        if len(addr_full)>2:
+            city = addr_full[1]
+            postcode = addr_full[2]
+        else:
+            city = addr_full[1].split(',')[0]
+            postcode = addr_full[1].split(',')[1]
+        if(len(location)>0):
+            lat = float( location[0][4:].split(",")[0])
+            lon = float( location[0][4:].split(",")[1])
+        else:
+            lat =''
+            lon=''
+        properties = {
+            'addr_full': addr_full[0],
+            'phone': response.xpath('normalize-space(//div[@id="cq-shop-info"]/p[@class="impinfo"]/text())').extract_first(),
+            'city':city,
+            'state': '',
+            'postcode': postcode,
+            'ref': response.url,
+            'website': response.url,
+            'lat': lat,
+            'lon': lon,
+        }
+
+        # hours = self.parse_hours(response.xpath('//ul[@class="cleanList srHours srSection"]/li'))
+        # if hours:
+        #     properties['opening_hours'] = hours
+
+        yield GeojsonPointItem(**properties)
+
+    def parse(self, response):
+        urls = response.xpath('//section[@class="shop-list"]/div[@class="shop-column"]/div[@class="shop-letter"]/ul/li/a/@href').extract()
+        for path in urls:
+            yield scrapy.Request(response.urljoin(path), callback=self.parse_stores)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Argos
Argos is... hard to describe. Probably best described as a department store.

http://www.argos.co.uk/stores/ <-- there's a full list of stores near the bottom of the page, no need to use the search interface.


Discussion:

Resolving patch:
diff --git a/locations/spiders/argos.py b/locations/spiders/argos.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/argos.py
@@ -0,0 +1,39 @@
+import scrapy
+import re
+import json
+from locations.items import GeojsonPointItem
+class ArgosSpider(scrapy.Spider):
+
+    name = "argos"
+    allowed_domains = ["www.argos.co.uk"]
+    download_delay = 0.5
+    start_urls = (
+        'http://www.argos.co.uk/stores/',
+    )
+    def parse_stores(self, response):
+        data = re.findall(r"window.INITIAL_STATE =[^<]+", response.body_as_unicode())
+        json_data = json.loads(data[0].replace("window.INITIAL_STATE =" ,''))
+        properties = {
+            'addr_full':json_data['store']['store']["address"],
+            'phone': json_data['store']['store']["tel"],
+            'city':json_data['store']['store']["town"],
+            'state': '',
+            'postcode': json_data['store']['store']["postcode"],
+            'ref': json_data['store']['store']["id"],
+            'website': response.url,
+            'lat': float(json_data['store']['store']["lat"]),
+            'lon': float(json_data['store']['store']["lng"]),
+        }
+
+        open_hours = ''
+        for item in json_data['store']['store']["storeTimes"]:
+          open_hours = open_hours + item['date'][ :2]+ ' ' + item['time']+' ;'
+        if open_hours:
+            properties['opening_hours'] = open_hours
+
+        yield GeojsonPointItem(**properties)
+
+    def parse(self, response):
+        urls = response.xpath('//div/div[@class="azsl-panel"]/ul/li/a/@href').extract()
+        for path in urls:
+            yield scrapy.Request(response.urljoin(path), callback=self.parse_stores)


Test patch:
Repository: alltheplaces/alltheplaces

Issue:
Homebase
Homebase is a hardware store chain in the UK.

https://www.homebase.co.uk/stores


Discussion:

Resolving patch:
diff --git a/locations/spiders/homebase.py b/locations/spiders/homebase.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/homebase.py
@@ -0,0 +1,39 @@
+import scrapy
+import re
+import json
+from locations.items import GeojsonPointItem
+class ArgosSpider(scrapy.Spider):
+
+    name = "homebase"
+    allowed_domains = ["www.homebase.co.uk"]
+    download_delay = 0.5
+    start_urls = (
+        'https://www.homebase.co.uk/stores',
+    )
+
+    def parse_stores(self, response):
+        data = re.findall(r"var com_bunnings_locations_mapLocations = [^;]+", response.body_as_unicode())
+        json_data = json.loads(data[0].replace("var com_bunnings_locations_mapLocations = " ,''))
+        properties = {
+            'addr_full': json_data[0]['Store']["Address"]["Address"] +json_data[0]['Store']["Address"]["AddressLineTwo"],
+            'phone': json_data[0]['Store']["Phone"],
+            'city': json_data[0]['Store']["Address"]["Suburb"],
+            'state': json_data[0]['Store']["Address"]["State"],
+            'postcode': json_data[0]['Store']["Address"]["Postcode"],
+            'country': json_data[0]['Store']["Address"]["Country"],
+            'ref': json_data[0]['Store']['StoreID'],
+            'website': response.url,
+            'lat': float(json_data[0]['Store']['Location']["Latitude"]),
+            'lon': float(json_data[0]['Store']['Location']["Longitude"]),
+        }
+
+        hours = response.xpath('//time[@itemprop="openingHours"]/@datatime').extract()
+        if hours != []:
+            properties['opening_hours'] = "; ".join(x for x in hours)
+
+        yield GeojsonPointItem(**properties)
+
+    def parse(self, response):
+        urls = response.xpath('//div[@class="store-listing__state__list alpha"]/ul/li/a/@href').extract()
+        for path in urls:
+            yield scrapy.Request(response.urljoin(path), callback=self.parse_stores)


Test patch: