Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
JE-Chen committed Jul 19, 2024
1 parent d72a11c commit 00ce93a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions je_mail_thunder/imap/imap_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def imap_later_init(self):
Try to log in
:return: None
"""
mail_thunder_logger.info(f"MT_imap_later_init")
mail_thunder_logger.info("MT_imap_later_init")
try:
self.imap_try_to_login_with_env_or_content()
except Exception as error:
Expand All @@ -38,15 +38,15 @@ def imap_try_to_login_with_env_or_content(self):
Try to find user and password on cwd /mail_thunder_content.json or env var
:return: None
"""
mail_thunder_logger.info(f"imap_try_to_login_with_env_or_content")
mail_thunder_logger.info("imap_try_to_login_with_env_or_content")
try:
user_info = read_output_content()
if user_info is not None and type(user_info) == dict:
if user_info is not None and isinstance(user_info, dict):
if user_info.get("user", None) is not None and user_info.get("password", None) is not None:
self.login(user_info.get("user"), user_info.get("password"))
else:
user_info = get_mail_thunder_os_environ()
if user_info is not None and type(user_info) == dict:
if user_info is not None and isinstance(user_info, dict):
if user_info.get("mail_thunder_user", None) is not None and user_info.get(
"mail_thunder_user_password", None) is not None:
self.login(user_info.get("mail_thunder_user"), user_info.get("mail_thunder_user_password"))
Expand Down
6 changes: 3 additions & 3 deletions je_mail_thunder/smtp/smtp_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ def smtp_try_to_login_with_env_or_content(self):
user_info = read_output_content()
self.login_state = False
try:
if user_info is not None and type(user_info) == dict:
if user_info is not None and isinstance(user_info, dict):
if user_info.get("user", None) is not None and user_info.get("password", None) is not None:
self.login(user_info.get("user"), user_info.get("password"))
self.login_state = True
else:
user_info = get_mail_thunder_os_environ()
if user_info is not None and type(user_info) == dict:
if user_info is not None and isinstance(user_info, dict):
if user_info.get("mail_thunder_user", None) is not None and user_info.get(
"mail_thunder_user_password", None) is not None:
self.login(user_info.get("mail_thunder_user"), user_info.get("mail_thunder_user_password"))
Expand All @@ -147,7 +147,7 @@ def quit(self):
Quit service and close connect
:return: None
"""
mail_thunder_logger.info(f"SMTP quit")
mail_thunder_logger.info("SMTP quit")
self.login_state = False

def smtp_create_message_with_attach_and_send(self, message_content: str, message_setting_dict: dict,
Expand Down
6 changes: 2 additions & 4 deletions je_mail_thunder/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ def execute_action(self, action_list: [list, dict]) -> dict:
for loop the list and execute action
"""
if isinstance(action_list, dict):
action_list: list = action_list.get("auto_control", None)
action_list: list = action_list.get("auto_control")
if action_list is None:
raise ExecuteActionException(executor_list_error)
execute_record_dict = dict()
try:
if len(action_list) > 0 or isinstance(action_list, list):
pass
else:
if len(action_list) < 0 or isinstance(action_list, list) is False:
raise ExecuteActionException(action_is_null_error)
except Exception as error:
mail_thunder_logger.error(
Expand Down
4 changes: 2 additions & 2 deletions je_mail_thunder/utils/scheduler/extend_apscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def add_blocking_job(
"""
params = locals()
params.pop("self")
trigger_args = params.pop("trigger_args")
params.pop("trigger_args")
return self._blocking_schedulers.add_job(**params, **trigger_args)

def add_nonblocking_job(
Expand Down Expand Up @@ -92,7 +92,7 @@ def add_nonblocking_job(
"""
params = locals()
params.pop("self")
trigger_args = params.pop("trigger_args")
params.pop("trigger_args")
return self._background_schedulers.add_job(**params, **trigger_args)

def get_blocking_scheduler(self) -> BlockingScheduler:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "je_mail_thunder_dev"
version = "0.0.34"
version = "0.0.36"
authors = [
{ name = "JE-Chen", email = "[email protected]" },
]
Expand Down

0 comments on commit 00ce93a

Please sign in to comment.