Skip to content

Commit

Permalink
Add --quick flag to speed up runs while testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Javex committed Sep 26, 2023
1 parent 1430a23 commit 6a0e87e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions woolies.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import requests
import json
import sys


class WooliesAPI:

def __init__(self):

def __init__(self, quick=False):
self.quick = quick


self.session = requests.Session()
Expand Down Expand Up @@ -71,7 +72,8 @@ def get_category(self, cat_id):
break

# Temporary speedup
break
if self.quick:
break

# Not done, go to next page
request_data['pageNumber'] += 1
Expand All @@ -96,7 +98,10 @@ def save_cache(cache_data):


def main():
woolies = WooliesAPI()
quick = False
if len(sys.argv) > 1 and sys.argv[1] == "--quick":
quick = True
woolies = WooliesAPI(quick=quick)
categories = woolies.get_categories()
#categories = load_cache()
for category_obj in categories:
Expand All @@ -117,6 +122,9 @@ def main():
category = woolies.get_category(cat_id)
all_category_bundles = list(category)
category_obj['Products'] = all_category_bundles

if quick:
break
#save_cache(categories)
with open('woolies_all.json', 'w') as f:
f.write(json.dumps(categories))
Expand Down

0 comments on commit 6a0e87e

Please sign in to comment.