Skip to content

Commit

Permalink
重构日志模块代码, fix #50
Browse files Browse the repository at this point in the history
  • Loading branch information
Nriver committed May 23, 2024
1 parent 54de8e9 commit 9f0afe7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
22 changes: 4 additions & 18 deletions EpisodeReName.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import argparse
import json
import os
import platform
import re
import sys
import time
from datetime import datetime

from custom_rules import starts_with_rules
from utils.config_utils import get_qrm_config
from utils.ep_utils import ep_format
from utils.ext_utils import COMPOUND_EXTS, get_file_name_ext, fix_ext
from utils.file_name_utils import clean_name, zero_fix, name_format_bypass_check
from utils.log_utils import logger
from utils.path_utils import (
format_path,
get_absolute_path,
Expand All @@ -21,22 +22,6 @@
from utils.season_utils import get_season_cascaded, get_season, get_season_path
from utils.series_utils import get_series_from_season_path

try:
from loguru import logger
except:
# 兼容无loguru模块的环境,例如docker和群晖
class logger:
def info(s):
print(f'| INFO | {s}')

def warning(s):
print(f'| WARNING | {s}')


# 应该能解析出大部分的命名规则了
# ''')
from custom_rules import starts_with_rules

# print('''
# -- 警告 --
# 如果用这个程序导致文件乱了后果自负哈哈哈哈哈哈哈
Expand All @@ -56,6 +41,8 @@ def warning(s):
# 括号没有
# 取剩余部分结尾的数字
# 部分特殊处理
# 应该能解析出大部分的命名规则了
# ''')

script_path = os.path.dirname(os.path.realpath(__file__))
target_path = ''
Expand Down Expand Up @@ -726,7 +713,6 @@ def ep_offset_patch(file_path, ep):
else:
logger.info('满足优先规则,重命名当前文件')


# 默认遇到文件存在则强制删除已存在文件
try:
# 检测文件能否重命名 报错直接忽略
Expand Down
10 changes: 10 additions & 0 deletions utils/log_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
try:
from loguru import logger
except:
# 兼容无loguru模块的环境,例如docker和群晖
class logger:
def info(s):
print(f'| INFO | {s}')

def warning(s):
print(f'| WARNING | {s}')
3 changes: 1 addition & 2 deletions utils/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import platform
import re

from loguru import logger

from utils.ext_utils import get_file_name_ext
from utils.log_utils import logger
from utils.season_utils import get_season_cascaded

# 当前系统类型
Expand Down

0 comments on commit 9f0afe7

Please sign in to comment.