Skip to content

Commit

Permalink
feat: add meta cfg parser
Browse files Browse the repository at this point in the history
  • Loading branch information
maksyuki committed Mar 14, 2024
1 parent 4bc3054 commit 33695a6
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ def check_proj_auth_ver(self, cfg_list: Dict[str,
#NOTE: no check the code
def check_notif(self, cfg_list: Dict[str, Any]) -> Tuple[bool, str]:
if cfg_list.get('notif') is not None:
(notif_mail, notif_ena) = cfg_list['notif']
if notif_ena != 'off' and notif_ena != 'on':
return (False, 'notif ena item value is wrong')

# HACK: add more detailed check function
if not '@' in notif_mail:
return (False, 'notif mail item value is wrong')

self.sub_cfg.meta_cfg.notif = cfg_list['notif']

notif = cfg_list['notif']

if notif.get('mail') is not None and notif.get('ena') is not None:
notif_mail = notif['mail']
notif_ena = notif['ena']
logging.info(
msg=f'notif_mail: {notif_mail} notif_ena: {notif_ena}')
if notif_ena != 'off' and notif_ena != 'on':
return (False, 'notif ena item value is wrong')

# HACK: add more detailed check function
if not '@' in notif_mail:
return (False, 'notif mail item value is wrong')

self.sub_cfg.meta_cfg.notif = (notif_mail, notif_ena)
logging.info(msg=f'[notif]: {cfg_list["notif"]}')
return (True, 'notif check done with no error')

def check_arch(self, cfg_list: Dict[str, Any]) -> Tuple[bool, str]:
Expand Down Expand Up @@ -206,6 +212,14 @@ def check_meta(self, cfg_list: Dict[str, Any]) -> Tuple[bool, str]:
if cfg_list.get('meta') is None:
return (False, 'dont have meta cfg table')

check_res = self.check_proj_auth_ver(cfg_list['meta'])
if check_res[0] is False:
return check_res

check_res = self.check_notif(cfg_list['meta'])
if check_res[0] is False:
return check_res

return (True, 'check meta cfg table done with no error')

def check_dut(self, cfg_list: Dict[str, Any]) -> Tuple[bool, str]:
Expand Down

0 comments on commit 33695a6

Please sign in to comment.