xtn-tools-pro 1.0.0.0.0__py3-none-any.whl → 1.0.0.0.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- xtn_tools_pro/tools.py +4 -2
- xtn_tools_pro/tools_flie.py +41 -0
- xtn_tools_pro/tools_time.py +1 -1
- {xtn_tools_pro-1.0.0.0.0.dist-info → xtn_tools_pro-1.0.0.0.1.dist-info}/METADATA +1 -1
- {xtn_tools_pro-1.0.0.0.0.dist-info → xtn_tools_pro-1.0.0.0.1.dist-info}/RECORD +8 -7
- {xtn_tools_pro-1.0.0.0.0.dist-info → xtn_tools_pro-1.0.0.0.1.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.0.0.0.dist-info → xtn_tools_pro-1.0.0.0.1.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.0.0.0.dist-info → xtn_tools_pro-1.0.0.0.1.dist-info}/top_level.txt +0 -0
xtn_tools_pro/tools.py
CHANGED
@@ -59,7 +59,6 @@ def get_file_md5_16(file_path):
|
|
59
59
|
return result[8:24]
|
60
60
|
|
61
61
|
|
62
|
-
|
63
62
|
def get_str_to_json(str_json):
|
64
63
|
"""
|
65
64
|
字符串类型的json格式 转 json
|
@@ -101,6 +100,9 @@ def get_calculate_total_page(total, limit):
|
|
101
100
|
return total_pages
|
102
101
|
|
103
102
|
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
104
107
|
if __name__ == '__main__':
|
105
108
|
pass
|
106
|
-
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 文件相关的工具
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2024/4/19 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
import os, re
|
12
|
+
|
13
|
+
|
14
|
+
def get_file_extension(file_name):
|
15
|
+
"""
|
16
|
+
根据文件名获取文件扩展名/后缀名
|
17
|
+
:param file_name: 文件名称
|
18
|
+
:return:
|
19
|
+
"""
|
20
|
+
_, file_extension = os.path.splitext(file_name)
|
21
|
+
return file_extension
|
22
|
+
|
23
|
+
|
24
|
+
def get_check_filename(file_name):
|
25
|
+
"""
|
26
|
+
传入文件名返回一个合法的文件名 会替换掉一些特殊符号 常用于爬虫写文件时文件名中带有特殊符号的情况...
|
27
|
+
:param filename: 文件名
|
28
|
+
:return:
|
29
|
+
"""
|
30
|
+
file_extension = get_file_extension(file_name)
|
31
|
+
# 删除非法字符
|
32
|
+
sanitized_filename = re.sub(r'[\/:*?"<>|]', '', file_name)
|
33
|
+
max_length = 255 # 操作系统限制文件名的最大长度为255个
|
34
|
+
sanitized_filename = sanitized_filename[:max_length]
|
35
|
+
return sanitized_filename
|
36
|
+
|
37
|
+
|
38
|
+
if __name__ == '__main__':
|
39
|
+
pass
|
40
|
+
print(get_file_extension('file/2024-04-19/BOSCH GEX 125-1A/125-1AE砂磨机操作说明书:[1]_jingyan.txt'))
|
41
|
+
print(get_check_filename('file/2024-04-19/BOSCH GEX 125-1A/125-1AE砂磨机操作说明书:[1]_jingyan.txt'))
|
xtn_tools_pro/tools_time.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
xtn_tools_pro/__init__.py,sha256=26Tf9j2wj88M1Ldg3b1DJ40KyGgN9ZmQdBLuV453388,395
|
2
|
-
xtn_tools_pro/tools.py,sha256=
|
3
|
-
xtn_tools_pro/
|
2
|
+
xtn_tools_pro/tools.py,sha256=e9KSPqaFBIptBGvexShCcn0nZmUQ5omlVwXgEfWZf5Y,2630
|
3
|
+
xtn_tools_pro/tools_flie.py,sha256=KuA1sowK31LuOfQMPRsQYPgxr8y7491caepRFYOwqG0,1507
|
4
|
+
xtn_tools_pro/tools_time.py,sha256=DMjsw9h4E_mrPsanPA8CEhpUE1AA6Z2FU4OJqJKZc1k,4867
|
4
5
|
xtn_tools_pro/db/MongoDB.py,sha256=_GiX1MHNl9CtI-uLDgY_NmMSvRJei-mtKq3Hhe6ly1E,5567
|
5
6
|
xtn_tools_pro/db/RedisDB.py,sha256=qMffCNIHa3o7KD_yVQlsj3OupsNXMsDPRi03migwSu0,4003
|
6
7
|
xtn_tools_pro/db/__init__.py,sha256=Zg91UWS02TO0Ba_0AY56s0oabRy93xLNFkpIIL_6mMM,416
|
@@ -17,8 +18,8 @@ xtnkk_tools_pro/tools_time.py,sha256=n4-T2tNSHnsh-X89IbjahCmoiDcmjZTKJlWyqGOmJQY
|
|
17
18
|
xtnkk_tools_pro/db/MongoDB.py,sha256=_GiX1MHNl9CtI-uLDgY_NmMSvRJei-mtKq3Hhe6ly1E,5567
|
18
19
|
xtnkk_tools_pro/db/RedisDB.py,sha256=qMffCNIHa3o7KD_yVQlsj3OupsNXMsDPRi03migwSu0,4003
|
19
20
|
xtnkk_tools_pro/db/__init__.py,sha256=Zg91UWS02TO0Ba_0AY56s0oabRy93xLNFkpIIL_6mMM,416
|
20
|
-
xtn_tools_pro-1.0.0.0.
|
21
|
-
xtn_tools_pro-1.0.0.0.
|
22
|
-
xtn_tools_pro-1.0.0.0.
|
23
|
-
xtn_tools_pro-1.0.0.0.
|
24
|
-
xtn_tools_pro-1.0.0.0.
|
21
|
+
xtn_tools_pro-1.0.0.0.1.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
+
xtn_tools_pro-1.0.0.0.1.dist-info/METADATA,sha256=cGqGoLCT0OxwP7KI82OKR1JUF9d9XnNk_Xg4DCgOSvU,333
|
23
|
+
xtn_tools_pro-1.0.0.0.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
24
|
+
xtn_tools_pro-1.0.0.0.1.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
25
|
+
xtn_tools_pro-1.0.0.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|