def validate_config(self, config):
"""????????????????"""
if self._validated:
return
for section in config.prefix("smtp_"):
smtp_config_items = config[section]
for rule in SMTPManager.config_rules:
item_value = smtp_config_items.get(rule.name)
rule.validate(item_value)
if item_value is None:
smtp_config_items[rule.name] = rule.default
if rule.name == "port" and isinstance(
item_value, types.StringTypes):
smtp_config_items["port"] = int(item_value)
smtp_config = SMTPConfig(**smtp_config_items)
self._all_smtp_config[section] = smtp_config
self._validated = True
评论列表
文章目录