# Path: legacy_codes/app/myLogger.py
# def viewLog(mode, data=None):
#     """
#     전달된 mode에 따라 로깅 내용이 달라진다.
#     message : 유저키, 타입, 내용을 기록한다. json형태의 data
#     add : 유저키를 기록한다. json형태의 data
#     block, exit : 유저키를 기록한다. string형태의 data
#     fail : 기본 request 처리 실패 로그
#     """
#     if mode is "message":
#         app.logger.info("[message] user_key : {}, type : {}, content : {}".format(
#             data["user_key"],
#             data["type"],
#             data["content"]))
#     elif mode is "scheduler":
#         app.logger.info("[parsing] data: {}".format(data))
#     elif mode is "query":
#         app.logger.info("[query] hakusiku {}".format(data))
#     elif mode is "review":
#         app.logger.info("[review] user_key: {}, review: {}".format(
#             data['user_key'],
#             data['content'],
#         ))
#     elif mode is "keyboard":
#         app.logger.info("[keyboard] call home keyboard")
#     elif mode is "add":
#         app.logger.info("[join] user_key : {}".format(data["user_key"]))
#     elif mode is "block":
#         app.logger.info("[block] user_key : {}".format(data))
#     elif mode is "exit":
#         app.logger.info("[exit] user_key : {}".format(data))
#     elif mode is "fail":
#         app.logger.info("[fail] request process fail log: {}".format(data))
# 
# Path: legacy_codes/app/parser.py
# class Singleton(type):
# class FoodParser:
# class SubwayParser(metaclass=Singleton):
# class BusParser(metaclass=Singleton):
# class LibParser(metaclass=Singleton):
#     def __call__(cls, *args, **kwargs):
#     def __init__(self):
#     def refresh(self, date=None):
#     def get_food(self, place):
#     def __init__(self):
#     def get_station_stat(self, station_name):
#     def __init__(self):
#     def get_station_stat(self, station_number):
#     def __init__(self):
#     def get_lib_stat(self):


import datetime
from .myLogger import viewLog
from .parser import food_api
            from .managers import DBAdmin
        from .managers import DBAdmin
                from .my_exception import FoodNotFound
            from .managers import DBAdmin
            from .managers import DBAdmin
            from .my_exception import FoodNotFound

    look_up_order = '조식 조식1 조식2 중식 중식1 중식2 중식3 석식 석식1 석식2 특식'.split()

    @staticmethod
    def fetch_save_menu(date=None):

        try:
            if DBAdmin.get_hakusiku_data(date):
                viewLog("fail", '오늘의 데이터는 이미 저장되어 있습니다.')
                return
            food_api.refresh(date)
            # dorm_foods = food_api.get_food("기식")
            date = date or datetime.date.today()
            day_of_week = date.weekday()
            # dorm_food = dorm_foods.get('월화수목금토일'[day_of_week])
            date = date.__str__()

            food_dict = {
                '푸드코트': food_api.get_food("푸드코트"),
                '학식': food_api.get_food("학식"),
                '교식': food_api.get_food("교식"),
                # '기식': dorm_food,
                '더 키친': food_api.get_food("더 키친"),
                '스넥코너': food_api.get_food("스넥코너"),
                '날짜': date,
            }
            viewLog('scheduler', food_dict)
            DBAdmin.set_hakusiku_data(food_dict, date)

        except Exception as e:

# Path: legacy_codes/app/myLogger.py
# def viewLog(mode, data=None):
#     """
#     전달된 mode에 따라 로깅 내용이 달라진다.
#     message : 유저키, 타입, 내용을 기록한다. json형태의 data
#     add : 유저키를 기록한다. json형태의 data
#     block, exit : 유저키를 기록한다. string형태의 data
#     fail : 기본 request 처리 실패 로그
#     """
#     if mode is "message":
#         app.logger.info("[message] user_key : {}, type : {}, content : {}".format(
#             data["user_key"],
#             data["type"],
#             data["content"]))
#     elif mode is "scheduler":
#         app.logger.info("[parsing] data: {}".format(data))
#     elif mode is "query":
#         app.logger.info("[query] hakusiku {}".format(data))
#     elif mode is "review":
#         app.logger.info("[review] user_key: {}, review: {}".format(
#             data['user_key'],
#             data['content'],
#         ))
#     elif mode is "keyboard":
#         app.logger.info("[keyboard] call home keyboard")
#     elif mode is "add":
#         app.logger.info("[join] user_key : {}".format(data["user_key"]))
#     elif mode is "block":
#         app.logger.info("[block] user_key : {}".format(data))
#     elif mode is "exit":
#         app.logger.info("[exit] user_key : {}".format(data))
#     elif mode is "fail":
#         app.logger.info("[fail] request process fail log: {}".format(data))
# 
# Path: legacy_codes/app/parser.py
# class Singleton(type):
# class FoodParser:
# class SubwayParser(metaclass=Singleton):
# class BusParser(metaclass=Singleton):
# class LibParser(metaclass=Singleton):
#     def __call__(cls, *args, **kwargs):
#     def __init__(self):
#     def refresh(self, date=None):
#     def get_food(self, place):
#     def __init__(self):
#     def get_station_stat(self, station_name):
#     def __init__(self):
#     def get_station_stat(self, station_number):
#     def __init__(self):
#     def get_lib_stat(self):


# Path: legacy_codes/app/menu.py
import datetime
from .myLogger import viewLog
from .parser import food_api
            from .managers import DBAdmin
        from .managers import DBAdmin
                from .my_exception import FoodNotFound
            from .managers import DBAdmin
            from .managers import DBAdmin
            from .my_exception import FoodNotFound


    look_up_order = '조식 조식1 조식2 중식 중식1 중식2 중식3 석식 석식1 석식2 특식'.split()

    @staticmethod
    def fetch_save_menu(date=None):

        try:
            if DBAdmin.get_hakusiku_data(date):
                viewLog("fail", '오늘의 데이터는 이미 저장되어 있습니다.')
                return
            food_api.refresh(date)
            # dorm_foods = food_api.get_food("기식")
            date = date or datetime.date.today()
            day_of_week = date.weekday()
            # dorm_food = dorm_foods.get('월화수목금토일'[day_of_week])
            date = date.__str__()

            food_dict = {
                '푸드코트': food_api.get_food("푸드코트"),
                '학식': food_api.get_food("학식"),
                '교식': food_api.get_food("교식"),
                # '기식': dorm_food,
                '더 키친': food_api.get_food("더 키친"),
                '스넥코너': food_api.get_food("스넥코너"),
                '날짜': date,
            }
            viewLog('scheduler', food_dict)
            DBAdmin.set_hakusiku_data(food_dict, date)

        except Exception as e:

            viewLog("fail", e)