upplib 3.2.1__tar.gz → 3.2.2__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.
- {upplib-3.2.1 → upplib-3.2.2}/PKG-INFO +1 -1
- {upplib-3.2.1 → upplib-3.2.2}/upplib/file.py +55 -56
- {upplib-3.2.1 → upplib-3.2.2}/upplib.egg-info/PKG-INFO +1 -1
- {upplib-3.2.1 → upplib-3.2.2}/LICENSE +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/README.md +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/pyproject.toml +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/setup.cfg +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/setup.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/__init__.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/chart.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/chart_html.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/clean_up_msg.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/common_package.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/db.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/file_text.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/format_data.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/http_util.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/index.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/mail.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/mail_html.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/markdown.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/multi_thread.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/query_log.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/redis_tool.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib/util.py +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib.egg-info/SOURCES.txt +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib.egg-info/dependency_links.txt +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib.egg-info/requires.txt +0 -0
- {upplib-3.2.1 → upplib-3.2.2}/upplib.egg-info/top_level.txt +0 -0
|
@@ -3,30 +3,30 @@ from upplib.index import *
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def get_file(file_path: str = None,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
path_startswith: str = None,
|
|
7
|
+
startswith: str = None,
|
|
8
8
|
path_contain: str = None,
|
|
9
9
|
contain: str = None,
|
|
10
10
|
sort_asc: bool | None = True,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
path_endswith: str = None,
|
|
12
|
+
endswith: str = None) -> list[str]:
|
|
13
13
|
"""
|
|
14
14
|
有关文件的操作
|
|
15
15
|
查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
|
|
16
|
-
file_path
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
path_contain
|
|
20
|
-
contain
|
|
21
|
-
sort_asc
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
file_path : 文件路径
|
|
17
|
+
path_startswith : 文件路径,以 path_startswith 开头
|
|
18
|
+
startswith : 文件名称,以 startswith 开头
|
|
19
|
+
path_contain : 文件路径,含有
|
|
20
|
+
contain : 文件名称,含有
|
|
21
|
+
sort_asc : 是否按升序排序,也就是从小到大排序
|
|
22
|
+
path_endswith : 文件路径,以 path_endswith 结尾
|
|
23
|
+
endswith : 文件名称,以 endswith 结尾
|
|
24
24
|
return list
|
|
25
25
|
"""
|
|
26
26
|
if file_path is None:
|
|
27
27
|
file_path = os.path.dirname(os.path.abspath('.'))
|
|
28
28
|
list_data = []
|
|
29
|
-
get_file_all(file_path, list_data,
|
|
29
|
+
get_file_all(file_path, list_data, path_startswith, startswith, path_contain, contain, path_endswith, endswith)
|
|
30
30
|
# 去一下重复的数据
|
|
31
31
|
r_list = list(set(list_data))
|
|
32
32
|
if sort_asc is not None:
|
|
@@ -50,30 +50,30 @@ def get_file_folder(file_name_one: str = None) -> str:
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def remove_folder_file(file_path: str = None,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
path_startswith: str = None,
|
|
54
|
+
startswith: str = None,
|
|
55
55
|
path_contain: str = None,
|
|
56
56
|
contain: str = None,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
path_endswith: str = None,
|
|
58
|
+
endswith: str = None):
|
|
59
59
|
"""
|
|
60
60
|
删除指定文件夹下面的指定的文件
|
|
61
61
|
"""
|
|
62
62
|
file_part_all_list = get_file(file_path=file_path,
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
path_startswith=path_startswith,
|
|
64
|
+
startswith=startswith,
|
|
65
65
|
path_contain=path_contain,
|
|
66
66
|
contain=contain,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
path_endswith=path_endswith,
|
|
68
|
+
endswith=endswith)
|
|
69
69
|
for file_part_all_one in file_part_all_list:
|
|
70
70
|
os.remove(file_part_all_one)
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def get_folder(file_path: str = None,
|
|
74
|
-
|
|
74
|
+
startswith: str = None,
|
|
75
75
|
contain: str = None,
|
|
76
|
-
|
|
76
|
+
endswith: str = None) -> list[str]:
|
|
77
77
|
"""
|
|
78
78
|
有关文件的操作, 只查询文件夹
|
|
79
79
|
查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
|
|
@@ -83,17 +83,17 @@ def get_folder(file_path: str = None,
|
|
|
83
83
|
if file_path is None:
|
|
84
84
|
file_path = os.path.dirname(os.path.abspath('.'))
|
|
85
85
|
list_data = []
|
|
86
|
-
get_folder_all(file_path, list_data,
|
|
86
|
+
get_folder_all(file_path, list_data, startswith, contain, endswith)
|
|
87
87
|
# 去一下重复的数据
|
|
88
88
|
return list(set(list_data))
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
# 是否包含指定的文件
|
|
92
92
|
def contain_file(file_path: str = None,
|
|
93
|
-
|
|
93
|
+
startswith: str = None,
|
|
94
94
|
contain: str = None,
|
|
95
|
-
|
|
96
|
-
return len(get_file(file_path,
|
|
95
|
+
endswith: str = None) -> bool:
|
|
96
|
+
return len(get_file(file_path, startswith, contain, endswith)) > 0
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def get_file_data_line(file_path: str = None,
|
|
@@ -125,78 +125,77 @@ def get_file_data_line(file_path: str = None,
|
|
|
125
125
|
# 查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
|
|
126
126
|
def get_file_all(file_path: str = None,
|
|
127
127
|
list_data: list = None,
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
path_startswith: str = None,
|
|
129
|
+
startswith: str = None,
|
|
130
130
|
path_contain: str = None,
|
|
131
131
|
contain: str = None,
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
path_endswith: str = None,
|
|
133
|
+
endswith: str = None) -> None:
|
|
134
134
|
if os.path.isdir(file_path):
|
|
135
135
|
for root, dir_names, file_names in os.walk(file_path):
|
|
136
136
|
for file_name in file_names:
|
|
137
|
-
if (get_file_check(os.path.join(root, file_name),
|
|
138
|
-
and get_file_check(file_name,
|
|
137
|
+
if (get_file_check(os.path.join(root, file_name), path_startswith, path_contain, path_endswith)
|
|
138
|
+
and get_file_check(file_name, startswith, contain, endswith)):
|
|
139
139
|
list_data.append(os.path.join(root, file_name))
|
|
140
140
|
for dir_name in dir_names:
|
|
141
|
-
get_file_all(os.path.join(root, dir_name), list_data,
|
|
142
|
-
elif (get_file_check(file_path,
|
|
143
|
-
and get_file_check(file_path,
|
|
141
|
+
get_file_all(os.path.join(root, dir_name), list_data, path_startswith, startswith, path_contain, contain, path_endswith, endswith)
|
|
142
|
+
elif (get_file_check(file_path, startswith, contain, endswith)
|
|
143
|
+
and get_file_check(file_path, path_startswith, path_contain, path_endswith)):
|
|
144
144
|
list_data.append(file_path)
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
# 查询指定文件夹下面的所有的文件信息, 也可以是指定的文件
|
|
148
148
|
def get_folder_all(file_path: str = None,
|
|
149
149
|
list_data: list = None,
|
|
150
|
-
|
|
150
|
+
startswith: str = None,
|
|
151
151
|
contain: str = None,
|
|
152
|
-
|
|
152
|
+
endswith: str = None) -> None:
|
|
153
153
|
if os.path.isdir(file_path):
|
|
154
154
|
for root, dir_names, file_names in os.walk(file_path):
|
|
155
155
|
for dir_name in dir_names:
|
|
156
156
|
dir_name_path = os.path.join(root, dir_name)
|
|
157
|
-
if get_file_check(dir_name_path,
|
|
157
|
+
if get_file_check(dir_name_path, startswith, contain, endswith):
|
|
158
158
|
list_data.append(dir_name_path)
|
|
159
159
|
else:
|
|
160
|
-
get_folder_all(dir_name_path, list_data,
|
|
160
|
+
get_folder_all(dir_name_path, list_data, startswith, contain, endswith)
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
def get_file_check(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
suffix: str = None) -> bool:
|
|
163
|
+
def get_file_check(name: str = None,
|
|
164
|
+
startswith: str = None,
|
|
165
|
+
contain: str = None,
|
|
166
|
+
endswith: str = None) -> bool:
|
|
168
167
|
"""
|
|
169
168
|
检查文件是否符合要求
|
|
170
|
-
|
|
171
|
-
contain
|
|
172
|
-
|
|
169
|
+
startswith : 以这个开头
|
|
170
|
+
contain : 包含这个字符
|
|
171
|
+
endswith : 以这个结尾
|
|
173
172
|
"""
|
|
174
173
|
if name is None or name == '':
|
|
175
174
|
return False
|
|
176
175
|
p = True
|
|
177
176
|
c = True
|
|
178
177
|
s = True
|
|
179
|
-
if
|
|
180
|
-
p = name.startswith(
|
|
178
|
+
if startswith is not None:
|
|
179
|
+
p = name.startswith(startswith)
|
|
181
180
|
if contain is not None:
|
|
182
181
|
c = name.find(contain) > -1
|
|
183
|
-
if
|
|
184
|
-
s = name.endswith(
|
|
182
|
+
if endswith is not None:
|
|
183
|
+
s = name.endswith(endswith)
|
|
185
184
|
return p and c and s
|
|
186
185
|
|
|
187
186
|
|
|
188
187
|
def find_file_by_content(file_path: str = '',
|
|
189
188
|
contain_txt: str = None,
|
|
190
|
-
|
|
189
|
+
startswith: str = None,
|
|
191
190
|
contain: str = None,
|
|
192
|
-
|
|
191
|
+
endswith: str = None) -> bool | None:
|
|
193
192
|
"""
|
|
194
193
|
检查文件内容是否包含指定的字符串
|
|
195
194
|
慎用,否则, 执行时间可能比较长
|
|
196
195
|
"""
|
|
197
|
-
list_file = get_file(file_path,
|
|
196
|
+
list_file = get_file(file_path, startswith, contain, endswith)
|
|
198
197
|
if len(list_file) == 0:
|
|
199
|
-
to_log(f'no_matched_file : {file_path} , {contain_txt} , {
|
|
198
|
+
to_log(f'no_matched_file : {file_path} , {contain_txt} , {startswith} , {contain} , {endswith}')
|
|
200
199
|
return False
|
|
201
200
|
if contain_txt is None:
|
|
202
201
|
to_log(list_file)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|