ocp5/config.py

95 lines
2.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Author: freezed <freezed@users.noreply.github.com> 2018-07-27
Version: 0.1
Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/
This file is part of [ocp5](https://github.com/freezed/ocp5) project
"""
# API
FIELD_KEPT = {
'product': [
'product_name',
'nutrition_grades',
'categories_tags'
],
'category': [
'_id',
'url',
'product_name',
'nutrition_grades',
'categories_tags'
]
}
2018-08-04 16:34:10 +00:00
# CLI
DB_REQUEST = {
'list_cat': "SELECT c.name, COUNT(*) AS 'option' FROM category AS c JOIN product AS p ON p.category_id = c.id GROUP BY c.name ORDER BY COUNT(*) DESC;",
'list_prod': "SELECT p.name, p.nutrition_grades AS 'option' FROM product AS p LEFT JOIN category AS c ON p.category_id = c.id WHERE c.name = '{}';",
'list_substitute': "SELECT p.name, p.nutrition_grades AS 'option' FROM product AS p LEFT JOIN category AS c ON p.category_id = c.id WHERE c.name = '{}' AND p.nutrition_grades < '{}'",
'select_substitute': "SELECT p.*, c.name FROM product AS p LEFT JOIN category AS c ON p.category_id = c.id WHERE p.name = '{}'",
2018-08-04 16:34:10 +00:00
'save_substitute': "UPDATE product SET substitute_id={} WHERE id={}",
}
CLI_MSG_DISCLAIMER = "# # # Bienvenu sur le terminal # # #\n\n"
CLI_MSG_CAT = "Catégories disponibles :\n"
2018-08-07 00:54:46 +00:00
CLI_MSG_PROD = "Produits disponibles :\n"
CLI_MSG_SUBST = "Substituts disponibles :\n"
CLI_MSG_ASK_IDX = "Index choisi [0-{}] («Q»uitter) :"
CLI_MSG_ASK_BAK = "Voulez vous sauvegarder «{}» en substitut du produit «{}»?"\
" [O/N]\n(«Q» pour quitter): "
2018-08-07 00:54:46 +00:00
CLI_MSG_CHOOSEN_CAT = "# # Categorie : [ {} ]\n"
CLI_MSG_CHOOSEN_PROD = "# Produits : [ {} ]\n"
CLI_MSG_CHOOSEN_SUBST = "Fiche complète du substitut : [ {} ]\n"
CLI_MSG_DETAILLED_SUB = "Nutriscore [ {nutri} ]\tCode [ {code} ]"\
"\nURL:{url}"
CLI_MSG_NO_SUBST = "Pas de substitut trouvé pour le produit «{}» (nutriscore : «{}»)"
CLI_MSG_ASK_ERR = "\nSaisie incorrecte : «{}»"
CLI_MSG_QUIT = "\nAu revoir!"
#CLI_ITEM_MAX_LEN = 15
2018-08-04 16:34:10 +00:00
# DATABASE
DB_CONFIG = {
'host': 'localhost',
'user': 'loff',
2018-08-02 18:00:30 +00:00
'password': 'loff',
'db': 'loff',
2018-08-02 18:00:30 +00:00
'charset': 'utf8',
'autocommit': True,
'file': 'create-db-loff.sql'
}
DB_MSG_TEMPLATE = {
"database": "DB «{}» contains these tables :",
"db_created": "DB «{}» created\n\n",
"tables": "{}\n",
"dashboard": "DB size : {dbsize}\nTable 'product' has «{rowprod}» "
"row(s)\nTable 'category' has «{rowcat}» row(s)"
}
# POPULATE
POP_MSG_TEMPLATE = {
'work': '\n# # # # # #\tC A T E G O R Y --[ {} ]--',
'fetch': '\tFetching data over API…',
'insert': '\tInserting data into DB…',
'missing': '\t/!\\ [ {} ] do not exists /!\\',
# '': '',
}
CATEGORY_LIST = [
'ail',
'bio',
'blés',
'roti',
'edam',
'kits',
'farces',
'bars',
'insectes'
]