ezKit 1.11.8__tar.gz → 1.11.10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {ezkit-1.11.8/ezKit.egg-info → ezkit-1.11.10}/PKG-INFO +1 -1
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/utils.py +58 -3
- {ezkit-1.11.8 → ezkit-1.11.10/ezKit.egg-info}/PKG-INFO +1 -1
- {ezkit-1.11.8 → ezkit-1.11.10}/setup.py +1 -1
- {ezkit-1.11.8 → ezkit-1.11.10}/LICENSE +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/MANIFEST.in +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/README.md +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/__init__.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/_file.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/bottle.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/bottle_extensions.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/cipher.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/database.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/http.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/mongo.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/qywx.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/redis.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/sendemail.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/token.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit/xftp.py +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit.egg-info/SOURCES.txt +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit.egg-info/dependency_links.txt +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit.egg-info/requires.txt +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/ezKit.egg-info/top_level.txt +0 -0
- {ezkit-1.11.8 → ezkit-1.11.10}/setup.cfg +0 -0
@@ -3,9 +3,11 @@ import csv
|
|
3
3
|
import hashlib
|
4
4
|
import json
|
5
5
|
import os
|
6
|
+
import re
|
6
7
|
import subprocess
|
7
8
|
import time
|
8
9
|
import tomllib
|
10
|
+
from ast import literal_eval
|
9
11
|
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
|
10
12
|
from copy import deepcopy
|
11
13
|
from datetime import date, datetime, timedelta, timezone
|
@@ -16,6 +18,7 @@ from typing import Any, Callable
|
|
16
18
|
from urllib.parse import ParseResult, urlparse
|
17
19
|
from uuid import uuid4
|
18
20
|
|
21
|
+
import markdown
|
19
22
|
from loguru import logger
|
20
23
|
|
21
24
|
# --------------------------------------------------------------------------------------------------
|
@@ -73,11 +76,11 @@ def check_arguments(data: list) -> bool:
|
|
73
76
|
|
74
77
|
try:
|
75
78
|
if not isTrue(data, list):
|
76
|
-
logger.error(f"argument
|
79
|
+
logger.error(f"argument error: data {type(data)}")
|
77
80
|
return False
|
78
|
-
for arg, arg_type,
|
81
|
+
for arg, arg_type, info in data:
|
79
82
|
if not isTrue(arg, arg_type):
|
80
|
-
logger.error(f"argument
|
83
|
+
logger.error(f"argument error: {info} {type(arg)}")
|
81
84
|
return False
|
82
85
|
return True
|
83
86
|
except Exception as e:
|
@@ -1440,3 +1443,55 @@ def url_parse(
|
|
1440
1443
|
# logger.exception(exception)
|
1441
1444
|
# else:
|
1442
1445
|
# logger.error(exception)
|
1446
|
+
|
1447
|
+
|
1448
|
+
# --------------------------------------------------------------------------------------------------
|
1449
|
+
|
1450
|
+
|
1451
|
+
def markdown_to_html(markdown_file: str, html_file: str, title: str) -> bool:
|
1452
|
+
|
1453
|
+
info: str = "将 Markdown 转换为 HTML"
|
1454
|
+
|
1455
|
+
try:
|
1456
|
+
|
1457
|
+
logger.info(f"{info} [开始]")
|
1458
|
+
|
1459
|
+
if not check_arguments([
|
1460
|
+
(markdown_file, str, "markdown_to_html -> markdown_file"),
|
1461
|
+
(html_file, str, "markdown_to_html -> html_file"),
|
1462
|
+
(title, str, "markdown_to_html -> title"),
|
1463
|
+
]):
|
1464
|
+
return False
|
1465
|
+
|
1466
|
+
# 读取 HTML模版 文件
|
1467
|
+
logger.info(f"{info} [读取 HTML模版 文件]")
|
1468
|
+
html_template_file = f"{current_dir(__file__)}/markdown_to_html.template"
|
1469
|
+
with open(html_template_file, "r", encoding="utf-8") as _:
|
1470
|
+
html_template = _.read()
|
1471
|
+
|
1472
|
+
# 读取 Markdown 文件
|
1473
|
+
logger.info(f"{info} [读取 Markdown 文件: {markdown_file}]")
|
1474
|
+
with open(markdown_file, "r", encoding="utf-8") as _:
|
1475
|
+
markdown_content = _.read()
|
1476
|
+
|
1477
|
+
# 将 Markdown 转换为 HTML
|
1478
|
+
logger.info(f"{info} [将 Markdown 转换为 HTML]")
|
1479
|
+
html_body = markdown.markdown(markdown_content, extensions=['tables'])
|
1480
|
+
|
1481
|
+
# 构造完整的 HTML
|
1482
|
+
logger.info(f"{info} [构造完整的 HTML]")
|
1483
|
+
html_content = re.sub(r"\{title\}", title, html_template)
|
1484
|
+
html_content = re.sub(r"\{body\}", html_body, html_content)
|
1485
|
+
|
1486
|
+
# 保存为 HTML 文件
|
1487
|
+
logger.info(f"{info} [保存为 HTML 文件: {html_file}]")
|
1488
|
+
with open(html_file, "w", encoding='utf-8') as _:
|
1489
|
+
_.write(html_content)
|
1490
|
+
|
1491
|
+
logger.success(f"{info} [成功]")
|
1492
|
+
return True
|
1493
|
+
|
1494
|
+
except Exception as e:
|
1495
|
+
logger.error(f"{info} [错误]")
|
1496
|
+
logger.error(e)
|
1497
|
+
return False
|
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
|