Updates comments

This commit is contained in:
Fred Z 2018-08-09 13:20:03 +02:00
parent 3e252bd918
commit a9c3c2c480
2 changed files with 8 additions and 8 deletions

View File

@ -6,7 +6,7 @@ Author: freezed <freezed@users.noreply.github.com> 2018-07-24
Version: 0.1 Version: 0.1
Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/ Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/
Call OpenFF API to populate a local MariaDB/MySQL database with product data Call Open Food Facts API to populate a local MariaDB/MySQL database with product data
This DB will serve an CLI client which gives alternative products with better This DB will serve an CLI client which gives alternative products with better
nurition grade. nurition grade.
""" """
@ -17,7 +17,7 @@ from config import FIELD_KEPT, API_URL_CAT
def get_product(code, from_file=False): def get_product(code, from_file=False):
""" """
Call OpenFF API to get data of a single product Call Open Food Facts API to get data of a single product
:Tests ONLINE: :Tests ONLINE:
# >>> prod_beurre = get_product('3017760000109') # >>> prod_beurre = get_product('3017760000109')
@ -116,7 +116,7 @@ def get_product(code, from_file=False):
def get_category(name, from_file=False): def get_category(name, from_file=False):
""" """
Call OpenFF API to get data of products in a single category Call Open Food Facts API to get data of products in a single category
:return: Dict filled with products & kept fields :return: Dict filled with products & kept fields
@ -216,7 +216,7 @@ def get_category(name, from_file=False):
staging_data['products'].append(dict()) staging_data['products'].append(dict())
for field in FIELD_KEPT['category']: for field in FIELD_KEPT['category']:
# import pdb; pdb.set_trace()
if field in product_fields: if field in product_fields:
staging_data['products'][idx][field] = product_fields[field] staging_data['products'][idx][field] = product_fields[field]

View File

@ -6,7 +6,7 @@ Author: freezed <freezed@users.noreply.github.com> 2018-08-02
Version: 0.1 Version: 0.1
Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/ Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/
Populates local DB with data comming from OpenFF API Populates local DB with data comming from Open Food Facts API
:Tests: :Tests:
>>> CATEGORY_LIST.append('falsecategory') >>> CATEGORY_LIST.append('falsecategory')
@ -28,13 +28,13 @@ for category in CATEGORY_LIST:
print(POP_MSG_TEMPLATE['work'].format(category)) print(POP_MSG_TEMPLATE['work'].format(category))
print(POP_MSG_TEMPLATE['fetch']) print(POP_MSG_TEMPLATE['fetch'])
# get data # gets data
staging_data = get_category(category) staging_data = get_category(category)
# generate SQL # generates SQL
sql_list = sql_generator(staging_data) sql_list = sql_generator(staging_data)
# execute SQL # executes SQL
print(POP_MSG_TEMPLATE['insert'].format(category)) print(POP_MSG_TEMPLATE['insert'].format(category))
if sql_list is False: if sql_list is False: