markdown-img-icexmoon 0.4.0__py3-none-any.whl → 2.0.0__py3-none-any.whl
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.
- markdown_img/globalization.py +2 -0
- markdown_img/main.py +12 -2
- markdown_img/smms_img.py +4 -0
- markdown_img/tools/file_tools.py +19 -4
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/METADATA +52 -12
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/RECORD +10 -10
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/WHEEL +1 -1
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/entry_points.txt +0 -0
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info/licenses}/LICENSE +0 -0
- {markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/top_level.txt +0 -0
markdown_img/globalization.py
CHANGED
|
@@ -36,6 +36,7 @@ class Globalization:
|
|
|
36
36
|
"tencent_oss_info_saved": "腾讯云OSS信息已保存,请重新运行程序",
|
|
37
37
|
"undefined_error_info": "未定义错误,请联系开发者",
|
|
38
38
|
"deal_success": "已成功处理markdown文件",
|
|
39
|
+
"deal_success_with_detail": "已成功处理markdown文件,原文件{},处理后的文件{}",
|
|
39
40
|
"all_file_done": "所有markdown文档已处理完毕",
|
|
40
41
|
"recove_markdown_file": "已成功还原markdown文件{}的本地图库",
|
|
41
42
|
"images_number_is_not_equal": "文件{}中的图片数目与备份中的数目不相符,请自行确认",
|
|
@@ -135,6 +136,7 @@ class Globalization:
|
|
|
135
136
|
"tencent_oss_info_saved": "Tencent Cloud OSS information has been saved, please re-run the program",
|
|
136
137
|
"undefined_error_info": "Undefined error, please contact the developer",
|
|
137
138
|
"deal_success": "Successfully processed markdown files",
|
|
139
|
+
"deal_success_with_detail": "Successfully processed markdown files, old file {}, new file {}",
|
|
138
140
|
"all_file_done": "All markdown documents have been processed",
|
|
139
141
|
"recove_markdown_file": "The local gallery of markdown file {} has been successfully restored",
|
|
140
142
|
"images_number_is_not_equal": "The number of images in file {} does not match the number in the backup, please check yourself",
|
markdown_img/main.py
CHANGED
|
@@ -12,6 +12,7 @@ from .compress.compress_manager import CompressManager
|
|
|
12
12
|
from .config_backup import ConfigBackup
|
|
13
13
|
from .tools.file_tools import FileTools
|
|
14
14
|
import shutil
|
|
15
|
+
import sys
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class Main():
|
|
@@ -152,7 +153,8 @@ class Main():
|
|
|
152
153
|
shutil.copyfile(localImg, relativeLocalImage)
|
|
153
154
|
# 替换图片路径为相对路径
|
|
154
155
|
line = line.replace(
|
|
155
|
-
|
|
156
|
+
# 改为使用/而非\
|
|
157
|
+
localImg, "."+"/"+"images"+"/"+imgName)
|
|
156
158
|
copyFileOpen.write(line)
|
|
157
159
|
copyFileOpen.close()
|
|
158
160
|
# 保存原始文件备份
|
|
@@ -224,7 +226,15 @@ class Main():
|
|
|
224
226
|
self.dealMdFile(dir, self.__createWebImgCopy)
|
|
225
227
|
except UserException as e:
|
|
226
228
|
self.dealUserException(e)
|
|
227
|
-
|
|
229
|
+
# 如果是 windows 平台,优化终端显示,让显示包含文件链接
|
|
230
|
+
if sys.platform == 'win32':
|
|
231
|
+
absSourcePath = FileTools.getAbsolutePath(dir)
|
|
232
|
+
sourceLink = FileTools.getWindowsTerminalPathLink(dir, absSourcePath)
|
|
233
|
+
targetFileName = FileTools.getFileName(copyFilePath)
|
|
234
|
+
targetLink = FileTools.getWindowsTerminalPathLink(targetFileName, copyFilePath)
|
|
235
|
+
print(self.globalization.getText("deal_success_with_detail").format(sourceLink, targetLink))
|
|
236
|
+
else:
|
|
237
|
+
print(self.globalization.getText("deal_success"), dir)
|
|
228
238
|
print(self.globalization.getText("all_file_done"))
|
|
229
239
|
|
|
230
240
|
def outputHelpInfo(self):
|
markdown_img/smms_img.py
CHANGED
|
@@ -39,6 +39,10 @@ class SmmsImg():
|
|
|
39
39
|
images[MAX_SAME_TIME_DEAL:len(images)], results)
|
|
40
40
|
|
|
41
41
|
def uploadOne(self, localImg):
|
|
42
|
+
# 如果是 gif 而非静态图片,不压缩
|
|
43
|
+
if (localImg.endswith(".gif")):
|
|
44
|
+
imgService = ImgServiceManager.getImgService()
|
|
45
|
+
return imgService.upload(localImg)
|
|
42
46
|
# 如果设置了压缩选项,进行压缩
|
|
43
47
|
info = self.sysConfig.getCompressInfo()
|
|
44
48
|
if(info[Config.COMPRESS_INFO_STATUS] == "on"):
|
markdown_img/tools/file_tools.py
CHANGED
|
@@ -18,9 +18,9 @@ class FileTools:
|
|
|
18
18
|
if unit == cls.SIZE_KB:
|
|
19
19
|
size = size / 1024
|
|
20
20
|
elif unit == cls.SIZE_MB:
|
|
21
|
-
size = size/1024/1024
|
|
21
|
+
size = size / 1024 / 1024
|
|
22
22
|
elif unit == cls.SIZE_GB:
|
|
23
|
-
size = size/1024/1024/1024
|
|
23
|
+
size = size / 1024 / 1024 / 1024
|
|
24
24
|
return size
|
|
25
25
|
|
|
26
26
|
@classmethod
|
|
@@ -34,11 +34,26 @@ class FileTools:
|
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
36
|
def getFileName(cls, path: str) -> str:
|
|
37
|
-
|
|
37
|
+
"""返回路径中的文件名
|
|
38
38
|
path: 绝对路径或相对路径
|
|
39
|
-
|
|
39
|
+
"""
|
|
40
40
|
if path is None:
|
|
41
41
|
return None
|
|
42
42
|
config = Config()
|
|
43
43
|
parts = path.split(config.getPathSplit())
|
|
44
44
|
return parts[-1]
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def getWindowsTerminalPathLink(cls, name: str, path: str) -> str:
|
|
48
|
+
"""返回Windows终端的快捷方式路径
|
|
49
|
+
name: 路径名称
|
|
50
|
+
path: 路径
|
|
51
|
+
"""
|
|
52
|
+
return "\033]8;;{}\033\\{}\033]8;;\033\\".format(path, name)
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def getAbsolutePath(cls, path: str) -> str:
|
|
56
|
+
"""返回绝对路径
|
|
57
|
+
path: 相对路径
|
|
58
|
+
"""
|
|
59
|
+
return os.path.abspath(path)
|
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-img-icexmoon
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: A program for find and upload images in markdown file and will replace them.
|
|
5
5
|
Home-page: https://github.com/icexmoon/markdown-img
|
|
6
6
|
Author: icexmoon
|
|
7
7
|
Author-email: icexmoon@qq.com
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
License: Copyright (c) 2018 The Python Packaging Authority
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: homepage, https://github.com/icexmoon/markdown-img
|
|
28
|
+
Project-URL: documentation, https://github.com/icexmoon/markdown-img
|
|
29
|
+
Project-URL: repository, https://github.com/icexmoon/markdown-img
|
|
30
|
+
Project-URL: changelog, https://github.com/icexmoon/markdown-img
|
|
31
|
+
Keywords: markdown,image
|
|
32
|
+
Classifier: Programming Language :: Python
|
|
11
33
|
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.
|
|
34
|
+
Requires-Python: >=3.13
|
|
13
35
|
Description-Content-Type: text/markdown
|
|
14
36
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
Requires-Dist: qiniu
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
37
|
+
Requires-Dist: cos-python-sdk-v5>=1.9.41
|
|
38
|
+
Requires-Dist: pillow>=12.1.0
|
|
39
|
+
Requires-Dist: qiniu>=7.17.0
|
|
40
|
+
Requires-Dist: requests>=2.32.5
|
|
41
|
+
Requires-Dist: tinify>=1.7.1
|
|
42
|
+
Requires-Dist: upyun>=2.5.5
|
|
43
|
+
Dynamic: license-file
|
|
21
44
|
|
|
22
45
|
# Markdown-img User's Guide
|
|
23
46
|
|
|
@@ -263,6 +286,17 @@ pymdimg -m relative_img
|
|
|
263
286
|
> - In order to avoid the corruption of the original MD file caused by program errors, one original file will be kept and backed up in the backup subdirectory.
|
|
264
287
|
> - Because of the difference between Windows and Linux platform separators, there is no guarantee that the relative directories of both will behave properly.
|
|
265
288
|
|
|
289
|
+
## Secondary Development
|
|
290
|
+
|
|
291
|
+
The development toolchain has been migrated to uv. For the installation and usage of uv, you can refer to [Python Package Management Tool UV](https://blog.icexmoon.cn/archives/805.html).
|
|
292
|
+
|
|
293
|
+
You can run the test code in the project's root directory using the following command:
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
uv run test.py
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
The test directory is located at `tests`, and you need to prepare the test files and data yourself. For reference, you can look at the `tests example`.
|
|
266
300
|
|
|
267
301
|
## Acknowledgements
|
|
268
302
|
|
|
@@ -323,3 +357,9 @@ Added the function to modify the absolute path image in the MD file to relative
|
|
|
323
357
|
### 0.4.0
|
|
324
358
|
|
|
325
359
|
Added the support to fengzhen image bed.
|
|
360
|
+
|
|
361
|
+
### 2.0.0
|
|
362
|
+
|
|
363
|
+
Migrate the development workflow to uv.
|
|
364
|
+
|
|
365
|
+
Optimize the display performance of the terminal on Windows, show the filenames before and after processing, and allow clicking on the filenames to jump to the corresponding files.
|
|
@@ -3,14 +3,14 @@ markdown_img/__main__.py,sha256=a4Fyl_gjDgwOVcWEdqXMlB10rVrX4Kkqri0jTel_HYs,3780
|
|
|
3
3
|
markdown_img/config.py,sha256=YxsTYkZOFNvoCfKPlFnEVg7doE3s3pwW5E5q3CTJ3e0,10848
|
|
4
4
|
markdown_img/config_backup.py,sha256=0xnrYgZ0Z6u3p-NkYkYX8xjZ7hESdWXI1Bem_65D3g4,3001
|
|
5
5
|
markdown_img/download_help.py,sha256=rRxYoaC8e7cLQZC4WGp4yegAGH4VLr85ATjFZAWEn04,1201
|
|
6
|
-
markdown_img/globalization.py,sha256=
|
|
6
|
+
markdown_img/globalization.py,sha256=kqPTYx8fwQ5WXFtJu_CJ17GWkqNmbqQ_uH3Fa9iZbGM,16983
|
|
7
7
|
markdown_img/help.info,sha256=4XdTWxoUpmlb95NOmoH8c5G92PDUcIAfZWAs0EWVgS4,2570
|
|
8
8
|
markdown_img/help_en.info,sha256=bwBxksZ0fwPmQanLRCZVWQtiyQK5pdlY-BuftLng0GE,2996
|
|
9
9
|
markdown_img/img_service_manager.py,sha256=hD7RCge7Qn7TInGZV-ZExfOegL3yIu7Ll0WI7SiVAXc,4826
|
|
10
|
-
markdown_img/main.py,sha256=
|
|
10
|
+
markdown_img/main.py,sha256=8SY9eoDROjllSLLye3BEkFD3KVmK8f7GpKoEuj1O77M,24916
|
|
11
11
|
markdown_img/qcloud_client.py,sha256=hQdQK9kBJbqQjO5cNaD6tjGol5sueH2hxP-hbM82yVc,2658
|
|
12
12
|
markdown_img/qiniu_client.py,sha256=iXb9otEj3JX4QPf0YOSmmZ2XO0eHjPJJDMV_JfPn-7E,1259
|
|
13
|
-
markdown_img/smms_img.py,sha256=
|
|
13
|
+
markdown_img/smms_img.py,sha256=OziO9o5ON05EQiLTIilOu0wAj9FOdv8jXsFGMuCZhh8,2539
|
|
14
14
|
markdown_img/time_helper.py,sha256=nmh8YxUoGsudCtywk3hjguuj3KczYPqwbcm_3g-gcYU,710
|
|
15
15
|
markdown_img/user_exception.py,sha256=Nu0d629DJFspIrNNmnV8rpTgp_1A3EU0M3gCpssWBYA,655
|
|
16
16
|
markdown_img/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -33,11 +33,11 @@ markdown_img/img_service/vimcn_img_service.py,sha256=fuMyw38vkUOvYjMi9cyCU6e6inO
|
|
|
33
33
|
markdown_img/img_service/yujian_img_service.py,sha256=Vm_RPzqsBElsoV1O9WlIlnWNjgdxkMvRWNaEMWcyxf4,3663
|
|
34
34
|
markdown_img/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
markdown_img/tools/debug.py,sha256=ja_hrJV3kHF9xjSMTJCfrKP8yv4BCWWtRZwcsBMXodk,340
|
|
36
|
-
markdown_img/tools/file_tools.py,sha256=
|
|
36
|
+
markdown_img/tools/file_tools.py,sha256=_k8l2zfU3Ezwv5x0t6q3ocDIEfmnfq4GXTDVF9eumoo,1698
|
|
37
37
|
markdown_img/tools/my_time.py,sha256=EwtBktfzVA6oFrWatzNUVncORR32XlLPo6dKGD1hpyQ,181
|
|
38
|
-
markdown_img_icexmoon-0.
|
|
39
|
-
markdown_img_icexmoon-0.
|
|
40
|
-
markdown_img_icexmoon-0.
|
|
41
|
-
markdown_img_icexmoon-0.
|
|
42
|
-
markdown_img_icexmoon-0.
|
|
43
|
-
markdown_img_icexmoon-0.
|
|
38
|
+
markdown_img_icexmoon-2.0.0.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
39
|
+
markdown_img_icexmoon-2.0.0.dist-info/METADATA,sha256=D1xKvgPy8YaTSQ5nayjP8xfhSVtcr19BeZimn0pJd84,22818
|
|
40
|
+
markdown_img_icexmoon-2.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
41
|
+
markdown_img_icexmoon-2.0.0.dist-info/entry_points.txt,sha256=Bts6o2l_i_ugWfMJcXicmG62vkqpkNM9RPF3ecRqJz0,55
|
|
42
|
+
markdown_img_icexmoon-2.0.0.dist-info/top_level.txt,sha256=hv32rwsEalALIYhSivTuOK17QqDeRD8RiNm_BuLIdk4,13
|
|
43
|
+
markdown_img_icexmoon-2.0.0.dist-info/RECORD,,
|
{markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
{markdown_img_icexmoon-0.4.0.dist-info → markdown_img_icexmoon-2.0.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|