def download_breweries(): BreweryDb.configure('c7aeca2c6fa21f8a51e023c80332a870') # response = BreweryDb.beers({'withBreweries':'Y','withIngredients':'Y'}) response = BreweryDb.breweries() totalPages = response['numberOfPages'] hops_data = response['data'] hops_dict_list = parse_hops_data(hops_data) variables = [x for x in dir(Brewery) if not (x.startswith('_'))] hops_count = 0 print "Starting to process page 1 of %d " % totalPages with open('brewery-brewerydb.csv', 'w') as csvFile: writer = DictUnicodeWriter(csvFile, variables) print "Wrote header" writer.writeheader() writer.writerows(hops_dict_list) hops_count += len(hops_dict_list) print "Wrote %d beers to file " % hops_count for page in range(2, totalPages + 1, 1): print "Retrieving data for page %d of total %d" % (page, totalPages) response = BreweryDb.breweries({'p': page}) beer_dict_list = parse_hops_data(response['data']) write_hops_to_csv('brewery-brewerydb.csv', variables, beer_dict_list) hops_count += len(beer_dict_list) print "Wrote %d beers to file " % hops_count
def method_to_invoke_with_params(self, params): return BreweryDb.breweries(params)
def method_to_invoke(self): return BreweryDb.breweries()