has added a CSV format promotions file when running --promos. Item.py was added for moduling.

This commit is contained in:
KorenLazar
2021-01-28 16:25:38 +02:00
parent 47c0d04ce4
commit d7e5b709f8
8 changed files with 94 additions and 29 deletions

View File

@@ -4,6 +4,8 @@ from argparse import ArgumentTypeError
from typing import Dict, List
from bs4.element import Tag
from item import Item
class SupermarketChain:
"""
@@ -72,17 +74,20 @@ class SupermarketChain:
@staticmethod
@abstractmethod
def get_items(promo: Tag, items_dict: Dict[str, str]) -> List[str]:
def get_items(promo: Tag, items_dict: Dict[str, Item]) -> List[Item]:
"""
This method returns a list of the items that participate in a given promo
This method returns a list of the items that participate in a given promotion.
:param promo: A given promo
:param promo: A given promotion
:param items_dict: A given dictionary of products
"""
pass
@staticmethod
def get_null_items(promo: Tag, items_dict: Dict[str, str]) -> List[str]:
def get_null_items(promo: Tag, items_dict: Dict[str, Item]) -> List[str]:
"""
This function returns all the items in a given promotion which do not appear in the given items_dict.
"""
return [item.find('ItemCode').text for item in promo.find_all('Item')
if not items_dict.get(item.find('ItemCode').text)]