upplib 2.9.5__tar.gz → 3.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {upplib-2.9.5 → upplib-3.3.4}/PKG-INFO +1 -1
  2. {upplib-2.9.5 → upplib-3.3.4}/upplib/__init__.py +4 -0
  3. {upplib-2.9.5 → upplib-3.3.4}/upplib/clean_up_msg.py +36 -12
  4. upplib-3.3.4/upplib/config_data.py +71 -0
  5. {upplib-2.9.5 → upplib-3.3.4}/upplib/db.py +0 -4
  6. {upplib-2.9.5 → upplib-3.3.4}/upplib/file.py +89 -48
  7. upplib-2.9.5/upplib/index.py → upplib-3.3.4/upplib/file_text.py +66 -821
  8. upplib-3.3.4/upplib/format_data.py +198 -0
  9. upplib-3.3.4/upplib/index.py +707 -0
  10. {upplib-2.9.5 → upplib-3.3.4}/upplib/query_log.py +93 -20
  11. {upplib-2.9.5 → upplib-3.3.4}/upplib/redis_tool.py +1 -1
  12. {upplib-2.9.5 → upplib-3.3.4}/upplib/util.py +6 -4
  13. {upplib-2.9.5 → upplib-3.3.4}/upplib.egg-info/PKG-INFO +1 -1
  14. {upplib-2.9.5 → upplib-3.3.4}/upplib.egg-info/SOURCES.txt +3 -0
  15. {upplib-2.9.5 → upplib-3.3.4}/LICENSE +0 -0
  16. {upplib-2.9.5 → upplib-3.3.4}/README.md +0 -0
  17. {upplib-2.9.5 → upplib-3.3.4}/pyproject.toml +0 -0
  18. {upplib-2.9.5 → upplib-3.3.4}/setup.cfg +0 -0
  19. {upplib-2.9.5 → upplib-3.3.4}/setup.py +0 -0
  20. {upplib-2.9.5 → upplib-3.3.4}/upplib/chart.py +0 -0
  21. {upplib-2.9.5 → upplib-3.3.4}/upplib/chart_html.py +0 -0
  22. {upplib-2.9.5 → upplib-3.3.4}/upplib/common_package.py +0 -0
  23. {upplib-2.9.5 → upplib-3.3.4}/upplib/http_util.py +0 -0
  24. {upplib-2.9.5 → upplib-3.3.4}/upplib/mail.py +0 -0
  25. {upplib-2.9.5 → upplib-3.3.4}/upplib/mail_html.py +0 -0
  26. {upplib-2.9.5 → upplib-3.3.4}/upplib/markdown.py +0 -0
  27. {upplib-2.9.5 → upplib-3.3.4}/upplib/multi_thread.py +0 -0
  28. {upplib-2.9.5 → upplib-3.3.4}/upplib.egg-info/dependency_links.txt +0 -0
  29. {upplib-2.9.5 → upplib-3.3.4}/upplib.egg-info/requires.txt +0 -0
  30. {upplib-2.9.5 → upplib-3.3.4}/upplib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: upplib
3
- Version: 2.9.5
3
+ Version: 3.3.4
4
4
  Summary: util
5
5
  Author: Luck
6
6
  Author-email: wantwaterfish@gmail.com
@@ -8,6 +8,9 @@ from upplib.util import *
8
8
 
9
9
  # 有关文件操作类的包
10
10
  from upplib.file import *
11
+ from upplib.file_text import *
12
+
13
+ from upplib.config_data import *
11
14
 
12
15
  # 有关 图表的 html 代码的包
13
16
  from upplib.chart_html import *
@@ -31,3 +34,4 @@ from upplib.multi_thread import *
31
34
 
32
35
  from upplib.query_log import *
33
36
  from upplib.redis_tool import *
37
+ from upplib.format_data import *
@@ -3,7 +3,31 @@ from datetime import datetime, timezone, timedelta
3
3
  from typing import Any, Optional, Union
4
4
 
5
5
 
6
- def clean_up_msg(msg: str = None, clean_up_type: int = 1, trace_id_fixed_length: int = None) -> str | None:
6
+ def simplify_msg(msg: str = None,
7
+ only_date_msg: bool = False,
8
+ msg_delete_prefix: int = 0,
9
+ ) -> str | None:
10
+ """
11
+ only_date_msg: 只输出日期+消息
12
+ msg_delete_prefix: 删除消息的前缀的数量
13
+ """
14
+ res_msg = msg
15
+ if only_date_msg:
16
+ # 只需要日期+消息的部分,其他的不需要了
17
+ msg_date = res_msg.partition(' ')[0]
18
+ msg_1 = res_msg.split(' - ')[2]
19
+ res_msg = msg_date.strip() + ' ' + msg_1.strip()
20
+ if msg_delete_prefix > 0:
21
+ msg_date, _, msg_1 = res_msg.partition(' ')
22
+ res_msg = msg_date.strip() + ' ' + msg_1.strip()[msg_delete_prefix:]
23
+ return res_msg
24
+
25
+
26
+ def clean_up_msg(msg: str = None,
27
+ clean_up_type: int = 1,
28
+ trace_id_fixed_length: int = None,
29
+ method_length: int = 31
30
+ ) -> str | None:
7
31
  if msg is None:
8
32
  return None
9
33
  formatters: list[Callable[[str], Optional[str]]] = [
@@ -17,7 +41,7 @@ def clean_up_msg(msg: str = None, clean_up_type: int = 1, trace_id_fixed_length:
17
41
  i + 1: formatter for i, formatter in enumerate(formatters)
18
42
  }
19
43
  if clean_up_type in formatter_map:
20
- return formatter_map[clean_up_type](msg, trace_id_fixed_length)
44
+ return formatter_map[clean_up_type](msg, trace_id_fixed_length, method_length)
21
45
  return msg
22
46
 
23
47
 
@@ -39,7 +63,7 @@ def get_thread_id_for_log(thread_id_str: str = None) -> str:
39
63
  return f' -{suffix}- '
40
64
 
41
65
 
42
- def clean_up_msg_1(msg: str = None, trace_id_fixed_length: int = None) -> str:
66
+ def clean_up_msg_1(msg: str = None, trace_id_fixed_length: int = None, method_length: int = 31) -> str:
43
67
  try:
44
68
  """
45
69
  2025-09-28T19:38:41.146111-06:00 com.leo.digest.aop.ApiLogAspect - traceId: - (catTraceId:rcs-gateway-0a0f2154-488625-102) - ===>API GatewayFacadeImpl#gatewayRequest START
@@ -61,7 +85,7 @@ def clean_up_msg_1(msg: str = None, trace_id_fixed_length: int = None) -> str:
61
85
  method, _, other = msg0.strip().partition(' - traceId:')
62
86
  other = msg0.strip() if not other else other
63
87
  thread_id = get_thread_id_for_log(method.strip().partition('] ')[0].rpartition('-')[2]) if '] ' in method else ' '
64
- method = method.strip()[-31:].rjust(31)
88
+ method = method.strip()[-method_length:].rjust(method_length)
65
89
  if '(catTraceId:' in other:
66
90
  trace_id = re.search(r'\(catTraceId:([^)]+)\)', other).group(1).strip()
67
91
  other_after = other.strip().partition(trace_id)[2][3:].strip()
@@ -81,7 +105,7 @@ def clean_up_msg_1(msg: str = None, trace_id_fixed_length: int = None) -> str:
81
105
  return msg
82
106
 
83
107
 
84
- def clean_up_msg_2(msg: str = None, trace_id_fixed_length: int = None) -> str:
108
+ def clean_up_msg_2(msg: str = None, trace_id_fixed_length: int = None, method_length: int = 31) -> str:
85
109
  try:
86
110
  """
87
111
  2025-10-09T13:45:49.687123+08:00 INFO 8 --- [nio-8080-exec-4] c.l.r.b.s.device.impl.DeviceServiceImpl : (catTraceId:customer-product-0a5a0329-488885-107496) - checkDeviceId lock key: 1073852969169211259
@@ -93,7 +117,7 @@ def clean_up_msg_2(msg: str = None, trace_id_fixed_length: int = None) -> str:
93
117
  time1, _, msg0 = msg.strip().partition(' ')
94
118
  thread_id = get_thread_id_for_log(msg0.strip().rpartition('] ')[0].rpartition('-')[2])
95
119
  method, _, other = msg0.strip().rpartition(' : ')
96
- method = method.strip()[-31:].rjust(31)
120
+ method = method.strip()[-method_length:].rjust(method_length)
97
121
  trace_id = ''
98
122
  if '(catTraceId:' in other:
99
123
  trace_id = re.search(r'\(catTraceId:([^)]+)\)', other).group(1)
@@ -105,7 +129,7 @@ def clean_up_msg_2(msg: str = None, trace_id_fixed_length: int = None) -> str:
105
129
  return msg
106
130
 
107
131
 
108
- def clean_up_msg_3(msg: str = None, trace_id_fixed_length: int = None) -> str:
132
+ def clean_up_msg_3(msg: str = None, trace_id_fixed_length: int = None, method_length: int = 31) -> str:
109
133
  try:
110
134
  """
111
135
  2025-10-09T14:25:28.096+07:00 INFO com.itn.idn.review.aop.LogAspect - traceId:db57046b7cba9d5c55fa5ff93727c4df - ReviewBackController.queryCreditCasesByUserIdsV2: request log info-------------> {"userIds":[1011450014961537063]}
@@ -114,7 +138,7 @@ def clean_up_msg_3(msg: str = None, trace_id_fixed_length: int = None) -> str:
114
138
  SEP_S = ' - traceId:'
115
139
  time1, _, msg0 = msg.strip().partition(' ')
116
140
  msg1 = msg0.strip().split(SEP_S)
117
- method = ' ' + msg1[0].strip()[-31:].rjust(31)
141
+ method = ' ' + msg1[0].strip()[-method_length:].rjust(method_length)
118
142
  trace_id, _, other = msg1[1].strip().partition(' - ')
119
143
  trace_id = f' - {trace_id} - ' if trace_id else ' - '
120
144
  return f'{time1}{method}{trace_id}{other}'
@@ -122,7 +146,7 @@ def clean_up_msg_3(msg: str = None, trace_id_fixed_length: int = None) -> str:
122
146
  return msg
123
147
 
124
148
 
125
- def clean_up_msg_4(msg: str = None, trace_id_fixed_length: int = None) -> str:
149
+ def clean_up_msg_4(msg: str = None, trace_id_fixed_length: int = None, method_length: int = 15) -> str:
126
150
  try:
127
151
  """
128
152
  2025-10-11T10:49:24.071000+07:00 INFO [TID: N/A] [8] [strategyAsyncExecutor-1] [FlowExecutor] [-] [33f7a5cfed3548f9aa3cc39079d1e407]:(catTraceId:rcs-provider-server-0a1e0d61-488931-966531) - requestId has generated
@@ -138,7 +162,7 @@ def clean_up_msg_4(msg: str = None, trace_id_fixed_length: int = None) -> str:
138
162
  time1, _, msg0 = msg.strip().partition(' ')
139
163
  msg1 = msg0.split(SEP_S)
140
164
  thread_id = get_thread_id_for_log(msg1[2].strip().rpartition('-')[2])
141
- method = msg1[3].strip().strip()[-15:].strip().replace('[', '').rjust(15)
165
+ method = msg1[3].strip().strip()[-method_length:].strip().replace('[', '').rjust(method_length)
142
166
  if ']:(catTraceId:' in msg1[5]:
143
167
  trace_id = re.search(r'\(catTraceId:([^)]+)\)', msg0).group(1)
144
168
  other = msg0.partition(trace_id)[2][3:].strip()
@@ -152,7 +176,7 @@ def clean_up_msg_4(msg: str = None, trace_id_fixed_length: int = None) -> str:
152
176
  return msg
153
177
 
154
178
 
155
- def clean_up_msg_5(msg: str = None, trace_id_fixed_length: int = None) -> str:
179
+ def clean_up_msg_5(msg: str = None, trace_id_fixed_length: int = None, method_length: int = 31) -> str:
156
180
  try:
157
181
  """
158
182
  2025-10-10T09:59:36.118111+07:00 [http-nio-8080-exec-13][AUDIT.1070150904958674814][20251010095936118AUDIT04869][jcl_20250109000001][][MAIN] INFO - (catTraceId:xdecisionengine-0a1e0845-488906-400194) - putAll to context ,value={"app":"kredi","ip":"192.168.1.8","session_id":"","source_type":"ANDROID","product_name":"kredi"} - cn.xinfei.xdecision.engine.domain.context.PipelineContextHolder.()
@@ -173,7 +197,7 @@ def clean_up_msg_5(msg: str = None, trace_id_fixed_length: int = None) -> str:
173
197
  msg0, _, method = msg0.rpartition(' - ')
174
198
  else:
175
199
  method = msg0.rpartition(') - [')[2].strip().rpartition('] ')[0].strip()
176
- method = method.strip().replace('.()', '')[-31:].rjust(31)
200
+ method = method.strip().replace('.()', '')[-method_length:].rjust(method_length)
177
201
  trace_id = ''
178
202
  other = ''
179
203
  if '(catTraceId:' in msg0:
@@ -0,0 +1,71 @@
1
+ from upplib import *
2
+ from upplib.common_package import *
3
+ from upplib.file import *
4
+
5
+ __CONFIG_PATH = '.upp.config'
6
+
7
+ __CONFIG_PATH_BAK = '_upp.config'
8
+
9
+
10
+ # 将数据写入到 config 中
11
+ def set_config_data(file_name: str = 'config',
12
+ param: dict[str, Any] = None) -> None:
13
+ set_data_in_user_home(file_name, {} if param is None else param)
14
+
15
+
16
+ # 从 config 中获得 配置数据
17
+ def get_config_data(file_name: str = 'config') -> dict[str, Any]:
18
+ # print('get_config_data', file_name)
19
+ config_data = get_data_from_user_home(file_name)
20
+ # print('get_data_from_user_home', config_data)
21
+ if not config_data:
22
+ config_data = get_data_from_path(file_name)
23
+ # print('get_data_from_path', config_data)
24
+ return config_data
25
+
26
+
27
+ # 在当前用户的主目录中, 获得指定文件的数据
28
+ def get_data_from_user_home(file_name: str = 'config') -> dict[str, Any]:
29
+ return get_data_from_path(file_name, os.path.expanduser("~"))
30
+
31
+
32
+ # 将 data 数据,在当前用户的主目录中, 获得指定文件的数据
33
+ def set_data_in_user_home(file_name: str = 'config',
34
+ param: dict[str, Any] = None) -> None:
35
+ set_data_in_path(file_name, {} if param is None else param, os.path.expanduser("~"))
36
+
37
+
38
+ # 在当前的目录中, 获得指定文件的数据
39
+ def get_data_from_path(file_name: str = 'config',
40
+ file_path: str = None) -> dict[str, Any]:
41
+ param = get_data_from_path_detail(file_name, file_path, __CONFIG_PATH)
42
+ return param if param else get_data_from_path_detail(file_name, file_path, __CONFIG_PATH_BAK)
43
+
44
+
45
+ def get_data_from_path_detail(file_name: str = 'config',
46
+ file_path: str = None,
47
+ path_name: str = __CONFIG_PATH) -> dict[str, Any]:
48
+ config_path = file_path + '/' + path_name if file_path else path_name
49
+ # print('config_path_1', config_path)
50
+ if not os.path.exists(config_path):
51
+ # print('config_path_2', config_path)
52
+ return {}
53
+ file_path = config_path + '/' + file_name + '.json'
54
+ # print('config_path_3', file_path)
55
+ if not os.path.exists(file_path):
56
+ return {}
57
+ # print('to_json_from_file', file_path)
58
+ return to_json_from_file(file_path)
59
+
60
+
61
+ # 在当前的目录中, 设置数据到指定路径下
62
+ def set_data_in_path(file_name: str = 'config',
63
+ param: str = None,
64
+ file_path: str = '') -> None:
65
+ config_path = file_path + '/' + __CONFIG_PATH
66
+ if not os.path.exists(config_path):
67
+ os.mkdir(config_path)
68
+ file_path = config_path + '/' + file_name + '.json'
69
+ text_file = open(file_path, 'w', encoding='utf-8')
70
+ text_file.write(to_str({} if param is None else param))
71
+ text_file.close()
@@ -173,10 +173,6 @@ def extract_sql(log_content: str = '') -> tuple[str | None, str | None]:
173
173
  return sql, total_sql
174
174
 
175
175
 
176
- def format_sql(sql: str) -> str:
177
- return sqlparse.format(sql, reindent=True, keyword_case="upper")
178
-
179
-
180
176
  def deal_sql(sql: str) -> str:
181
177
  sql = sql.replace('\n', ' ')
182
178
  sql = re.sub(r'\s+', ' ', sql).strip()
@@ -1,38 +1,80 @@
1
1
  from upplib import *
2
2
  from upplib.index import *
3
+ from upplib.index import is_win
3
4
 
4
5
 
5
6
  def get_file(file_path: str = None,
6
- path_prefix: str = None,
7
- prefix: str = None,
7
+ path_startswith: str = None,
8
+ startswith: str = None,
8
9
  path_contain: str = None,
9
10
  contain: str = None,
10
- path_suffix: str = None,
11
- suffix: str = None) -> list[str]:
11
+ sort_asc: bool | None = True,
12
+ path_endswith: str = None,
13
+ endswith: str = None) -> list[str]:
12
14
  """
13
15
  有关文件的操作
14
16
  查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
15
- file_path : 文件路径
16
- path_prefix : 文件路径,以 prefix 开头
17
- prefix : 文件名称,以 prefix 开头
18
- path_contain : 文件路径,含有
19
- contain : 文件名称,含有
20
- path_suffix : 文件路径,以 suffix 结尾
21
- suffix : 文件名称,以 suffix 结尾
17
+ file_path : 文件路径
18
+ path_startswith : 文件路径,以 path_startswith 开头
19
+ startswith : 文件名称,以 startswith 开头
20
+ path_contain : 文件路径,含有
21
+ contain : 文件名称,含有
22
+ sort_asc : 是否按升序排序,也就是从小到大排序
23
+ path_endswith : 文件路径,以 path_endswith 结尾
24
+ endswith : 文件名称,以 endswith 结尾
22
25
  return list
23
26
  """
24
27
  if file_path is None:
25
28
  file_path = os.path.dirname(os.path.abspath('.'))
26
29
  list_data = []
27
- get_file_all(file_path, list_data, path_prefix, prefix, path_contain, contain, path_suffix, suffix)
30
+ get_file_all(file_path, list_data, path_startswith, startswith, path_contain, contain, path_endswith, endswith)
28
31
  # 去一下重复的数据
29
- return list(set(list_data))
32
+ r_list = list(set(list_data))
33
+ if sort_asc is not None:
34
+ if sort_asc:
35
+ r_list.sort(reverse=False)
36
+ else:
37
+ r_list.sort(reverse=True)
38
+ return r_list
39
+
40
+
41
+ def get_file_folder(file_name_one: str = None) -> str:
42
+ """
43
+ 返回这个文件的文件夹路径
44
+ param file_name_one : 这个文件的全路径
45
+ return str : 这个文件的文件夹路径
46
+ """
47
+ file_sep = '\\' if is_win() else '/'
48
+ file_name_list = file_name_one.split(file_sep)
49
+ all_file_path = file_sep.join(file_name_list[0:-1])
50
+ return all_file_path
51
+
52
+
53
+ def remove_folder_file(file_path: str = None,
54
+ path_startswith: str = None,
55
+ startswith: str = None,
56
+ path_contain: str = None,
57
+ contain: str = None,
58
+ path_endswith: str = None,
59
+ endswith: str = None):
60
+ """
61
+ 删除指定文件夹下面的指定的文件
62
+ """
63
+ file_part_all_list = get_file(file_path=file_path,
64
+ path_startswith=path_startswith,
65
+ startswith=startswith,
66
+ path_contain=path_contain,
67
+ contain=contain,
68
+ path_endswith=path_endswith,
69
+ endswith=endswith)
70
+ for file_part_all_one in file_part_all_list:
71
+ os.remove(file_part_all_one)
30
72
 
31
73
 
32
74
  def get_folder(file_path: str = None,
33
- prefix: str = None,
75
+ startswith: str = None,
34
76
  contain: str = None,
35
- suffix: str = None) -> list[str]:
77
+ endswith: str = None) -> list[str]:
36
78
  """
37
79
  有关文件的操作, 只查询文件夹
38
80
  查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
@@ -42,17 +84,17 @@ def get_folder(file_path: str = None,
42
84
  if file_path is None:
43
85
  file_path = os.path.dirname(os.path.abspath('.'))
44
86
  list_data = []
45
- get_folder_all(file_path, list_data, prefix, contain, suffix)
87
+ get_folder_all(file_path, list_data, startswith, contain, endswith)
46
88
  # 去一下重复的数据
47
89
  return list(set(list_data))
48
90
 
49
91
 
50
92
  # 是否包含指定的文件
51
93
  def contain_file(file_path: str = None,
52
- prefix: str = None,
94
+ startswith: str = None,
53
95
  contain: str = None,
54
- suffix: str = None) -> bool:
55
- return len(get_file(file_path, prefix, contain, suffix)) > 0
96
+ endswith: str = None) -> bool:
97
+ return len(get_file(file_path, startswith, contain, endswith)) > 0
56
98
 
57
99
 
58
100
  def get_file_data_line(file_path: str = None,
@@ -84,78 +126,77 @@ def get_file_data_line(file_path: str = None,
84
126
  # 查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
85
127
  def get_file_all(file_path: str = None,
86
128
  list_data: list = None,
87
- path_prefix: str = None,
88
- prefix: str = None,
129
+ path_startswith: str = None,
130
+ startswith: str = None,
89
131
  path_contain: str = None,
90
132
  contain: str = None,
91
- path_suffix: str = None,
92
- suffix: str = None) -> None:
133
+ path_endswith: str = None,
134
+ endswith: str = None) -> None:
93
135
  if os.path.isdir(file_path):
94
136
  for root, dir_names, file_names in os.walk(file_path):
95
137
  for file_name in file_names:
96
- if (get_file_check(os.path.join(root, file_name), path_prefix, path_contain, path_suffix)
97
- and get_file_check(file_name, prefix, contain, suffix)):
138
+ if (get_file_check(os.path.join(root, file_name), path_startswith, path_contain, path_endswith)
139
+ and get_file_check(file_name, startswith, contain, endswith)):
98
140
  list_data.append(os.path.join(root, file_name))
99
141
  for dir_name in dir_names:
100
- get_file_all(os.path.join(root, dir_name), list_data, path_prefix, prefix, path_contain, contain, path_suffix, suffix)
101
- elif (get_file_check(file_path, prefix, contain, suffix)
102
- and get_file_check(file_path, path_prefix, path_contain, path_suffix)):
142
+ get_file_all(os.path.join(root, dir_name), list_data, path_startswith, startswith, path_contain, contain, path_endswith, endswith)
143
+ elif (get_file_check(file_path, startswith, contain, endswith)
144
+ and get_file_check(file_path, path_startswith, path_contain, path_endswith)):
103
145
  list_data.append(file_path)
104
146
 
105
147
 
106
148
  # 查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
107
149
  def get_folder_all(file_path: str = None,
108
150
  list_data: list = None,
109
- prefix: str = None,
151
+ startswith: str = None,
110
152
  contain: str = None,
111
- suffix: str = None) -> None:
153
+ endswith: str = None) -> None:
112
154
  if os.path.isdir(file_path):
113
155
  for root, dir_names, file_names in os.walk(file_path):
114
156
  for dir_name in dir_names:
115
157
  dir_name_path = os.path.join(root, dir_name)
116
- if get_file_check(dir_name_path, prefix, contain, suffix):
158
+ if get_file_check(dir_name_path, startswith, contain, endswith):
117
159
  list_data.append(dir_name_path)
118
160
  else:
119
- get_folder_all(dir_name_path, list_data, prefix, contain, suffix)
161
+ get_folder_all(dir_name_path, list_data, startswith, contain, endswith)
120
162
 
121
163
 
122
- def get_file_check(
123
- name: str = None,
124
- prefix: str = None,
125
- contain: str = None,
126
- suffix: str = None) -> bool:
164
+ def get_file_check(name: str = None,
165
+ startswith: str = None,
166
+ contain: str = None,
167
+ endswith: str = None) -> bool:
127
168
  """
128
169
  检查文件是否符合要求
129
- prefix : 前缀
130
- contain : 包含这个字符
131
- suffix : 后缀
170
+ startswith : 以这个开头
171
+ contain : 包含这个字符
172
+ endswith : 以这个结尾
132
173
  """
133
174
  if name is None or name == '':
134
175
  return False
135
176
  p = True
136
177
  c = True
137
178
  s = True
138
- if prefix is not None:
139
- p = name.startswith(prefix)
179
+ if startswith is not None:
180
+ p = name.startswith(startswith)
140
181
  if contain is not None:
141
182
  c = name.find(contain) > -1
142
- if suffix is not None:
143
- s = name.endswith(suffix)
183
+ if endswith is not None:
184
+ s = name.endswith(endswith)
144
185
  return p and c and s
145
186
 
146
187
 
147
188
  def find_file_by_content(file_path: str = '',
148
189
  contain_txt: str = None,
149
- prefix: str = None,
190
+ startswith: str = None,
150
191
  contain: str = None,
151
- suffix: str = None) -> bool | None:
192
+ endswith: str = None) -> bool | None:
152
193
  """
153
194
  检查文件内容是否包含指定的字符串
154
195
  慎用,否则, 执行时间可能比较长
155
196
  """
156
- list_file = get_file(file_path, prefix, contain, suffix)
197
+ list_file = get_file(file_path, startswith, contain, endswith)
157
198
  if len(list_file) == 0:
158
- to_log(f'no_matched_file : {file_path} , {contain_txt} , {prefix} , {contain} , {suffix}')
199
+ to_log(f'no_matched_file : {file_path} , {contain_txt} , {startswith} , {contain} , {endswith}')
159
200
  return False
160
201
  if contain_txt is None:
161
202
  to_log(list_file)