upplib 3.2.2__py3-none-any.whl → 3.3.1__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.
- upplib/__init__.py +2 -0
- upplib/config_data.py +71 -0
- upplib/file.py +1 -0
- upplib/file_text.py +13 -16
- upplib/index.py +0 -68
- upplib/util.py +2 -3
- {upplib-3.2.2.dist-info → upplib-3.3.1.dist-info}/METADATA +1 -1
- {upplib-3.2.2.dist-info → upplib-3.3.1.dist-info}/RECORD +11 -10
- {upplib-3.2.2.dist-info → upplib-3.3.1.dist-info}/WHEEL +0 -0
- {upplib-3.2.2.dist-info → upplib-3.3.1.dist-info}/licenses/LICENSE +0 -0
- {upplib-3.2.2.dist-info → upplib-3.3.1.dist-info}/top_level.txt +0 -0
upplib/__init__.py
CHANGED
upplib/config_data.py
ADDED
|
@@ -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()
|
upplib/file.py
CHANGED
upplib/file_text.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
from upplib import *
|
|
2
|
-
from datetime import datetime, timezone, timedelta
|
|
3
|
-
from typing import Any, Optional, Union
|
|
4
2
|
from upplib.common_package import *
|
|
5
3
|
from upplib.file import get_file
|
|
6
|
-
from collections import defaultdict
|
|
7
4
|
|
|
8
5
|
|
|
9
6
|
def get_latest_file(file_path: str = None,
|
|
@@ -365,8 +362,8 @@ def to_list(file_name: str = 'a.txt',
|
|
|
365
362
|
sep_line_prefix: str = None,
|
|
366
363
|
sep_line_suffix: str = None,
|
|
367
364
|
sep_all: str = None,
|
|
368
|
-
|
|
369
|
-
|
|
365
|
+
line_ignore_start_with: list[str] | set[str] | str = None,
|
|
366
|
+
line_ignore_end_with: list[str] | set[str] | str | None = None,
|
|
370
367
|
start_index: int = None,
|
|
371
368
|
start_line: str = None,
|
|
372
369
|
end_index: int = None,
|
|
@@ -410,8 +407,8 @@ def to_list(file_name: str = 'a.txt',
|
|
|
410
407
|
sep_line_prefix=sep_line_prefix,
|
|
411
408
|
sep_line_suffix=sep_line_suffix,
|
|
412
409
|
sep_all=sep_all,
|
|
413
|
-
|
|
414
|
-
|
|
410
|
+
line_ignore_start_with=line_ignore_start_with,
|
|
411
|
+
line_ignore_end_with=line_ignore_end_with,
|
|
415
412
|
start_index=start_index,
|
|
416
413
|
start_line=start_line,
|
|
417
414
|
end_index=end_index,
|
|
@@ -820,16 +817,16 @@ def to_list_from_txt(file_name: str = 'a.txt',
|
|
|
820
817
|
# 读取文件中的数据,返回一个 str
|
|
821
818
|
def to_str_from_file(file_name: str = 'a.txt',
|
|
822
819
|
str_join: str = ' ',
|
|
823
|
-
|
|
824
|
-
|
|
820
|
+
line_ignore_start_with: list | int | str | None = None,
|
|
821
|
+
line_ignore_end_with: list | int | str | None = None,
|
|
825
822
|
start_index: int = None,
|
|
826
823
|
start_line: str = None,
|
|
827
824
|
end_index: int = None,
|
|
828
825
|
end_line: str = None,
|
|
829
826
|
count: int = None) -> str:
|
|
830
827
|
return to_data_from_file(file_name=file_name,
|
|
831
|
-
|
|
832
|
-
|
|
828
|
+
line_ignore_start_with=line_ignore_start_with,
|
|
829
|
+
line_ignore_end_with=line_ignore_end_with,
|
|
833
830
|
str_join=str_join,
|
|
834
831
|
start_index=start_index,
|
|
835
832
|
start_line=start_line,
|
|
@@ -851,7 +848,7 @@ def to_json_from_file(file_name: str = 'a.txt',
|
|
|
851
848
|
start_line=start_line,
|
|
852
849
|
end_index=end_index,
|
|
853
850
|
end_line=end_line,
|
|
854
|
-
|
|
851
|
+
line_ignore_start_with=['//', '/*', '#'],
|
|
855
852
|
count=count,
|
|
856
853
|
r_json=True)
|
|
857
854
|
|
|
@@ -860,8 +857,8 @@ def to_data_from_file(file_name: str = 'a.txt',
|
|
|
860
857
|
sep: str = None,
|
|
861
858
|
sep_line: str = None,
|
|
862
859
|
sep_all: str = None,
|
|
863
|
-
|
|
864
|
-
|
|
860
|
+
line_ignore_start_with: list | int | str | None = None,
|
|
861
|
+
line_ignore_end_with: list | int | str | None = None,
|
|
865
862
|
start_index: int = None,
|
|
866
863
|
start_line: str = None,
|
|
867
864
|
end_index: int = None,
|
|
@@ -884,8 +881,8 @@ def to_data_from_file(file_name: str = 'a.txt',
|
|
|
884
881
|
sep=sep,
|
|
885
882
|
sep_line=sep_line,
|
|
886
883
|
sep_all=sep_all,
|
|
887
|
-
|
|
888
|
-
|
|
884
|
+
line_ignore_start_with=line_ignore_start_with,
|
|
885
|
+
line_ignore_end_with=line_ignore_end_with,
|
|
889
886
|
start_index=start_index,
|
|
890
887
|
start_line=start_line,
|
|
891
888
|
end_index=end_index,
|
upplib/index.py
CHANGED
|
@@ -2,12 +2,8 @@ from upplib import *
|
|
|
2
2
|
from datetime import datetime, timezone, timedelta
|
|
3
3
|
from typing import Any, Optional, Union
|
|
4
4
|
from upplib.common_package import *
|
|
5
|
-
from upplib.file import get_file
|
|
6
5
|
from collections import defaultdict
|
|
7
6
|
|
|
8
|
-
__CONFIG_PATH = '.upp.config'
|
|
9
|
-
|
|
10
|
-
__CONFIG_PATH_BAK = '_upp.config'
|
|
11
7
|
|
|
12
8
|
# 创建一个线程本地存储对象
|
|
13
9
|
__THREAD_LOCAL_INDEX_DATA = threading.local()
|
|
@@ -566,70 +562,6 @@ def format_sorted_kv_string(data_obj: Any,
|
|
|
566
562
|
return sep.join(result)
|
|
567
563
|
|
|
568
564
|
|
|
569
|
-
# 将数据写入到 config 中
|
|
570
|
-
def set_config_data(file_name: str = 'config',
|
|
571
|
-
param: dict[str, Any] = None) -> None:
|
|
572
|
-
set_data_in_user_home(file_name, {} if param is None else param)
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
# 从 config 中获得 配置数据
|
|
576
|
-
def get_config_data(file_name: str = 'config') -> dict[str, Any]:
|
|
577
|
-
# print('get_config_data', file_name)
|
|
578
|
-
config_data = get_data_from_user_home(file_name)
|
|
579
|
-
# print('get_data_from_user_home', config_data)
|
|
580
|
-
if not config_data:
|
|
581
|
-
config_data = get_data_from_path(file_name)
|
|
582
|
-
# print('get_data_from_path', config_data)
|
|
583
|
-
return config_data
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
# 在当前用户的主目录中, 获得指定文件的数据
|
|
587
|
-
def get_data_from_user_home(file_name: str = 'config') -> dict[str, Any]:
|
|
588
|
-
return get_data_from_path(file_name, os.path.expanduser("~"))
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
# 将 data 数据,在当前用户的主目录中, 获得指定文件的数据
|
|
592
|
-
def set_data_in_user_home(file_name: str = 'config',
|
|
593
|
-
param: dict[str, Any] = None) -> None:
|
|
594
|
-
set_data_in_path(file_name, {} if param is None else param, os.path.expanduser("~"))
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
# 在当前的目录中, 获得指定文件的数据
|
|
598
|
-
def get_data_from_path(file_name: str = 'config',
|
|
599
|
-
file_path: str = None) -> dict[str, Any]:
|
|
600
|
-
param = get_data_from_path_detail(file_name, file_path, __CONFIG_PATH)
|
|
601
|
-
return param if param else get_data_from_path_detail(file_name, file_path, __CONFIG_PATH_BAK)
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
def get_data_from_path_detail(file_name: str = 'config',
|
|
605
|
-
file_path: str = None,
|
|
606
|
-
path_name: str = __CONFIG_PATH) -> dict[str, Any]:
|
|
607
|
-
config_path = file_path + '/' + path_name if file_path else path_name
|
|
608
|
-
# print('config_path_1', config_path)
|
|
609
|
-
if not os.path.exists(config_path):
|
|
610
|
-
# print('config_path_2', config_path)
|
|
611
|
-
return {}
|
|
612
|
-
file_path = config_path + '/' + file_name + '.json'
|
|
613
|
-
# print('config_path_3', file_path)
|
|
614
|
-
if not os.path.exists(file_path):
|
|
615
|
-
return {}
|
|
616
|
-
# print('to_json_from_file', file_path)
|
|
617
|
-
return to_json_from_file(file_path)
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
# 在当前的目录中, 设置数据到指定路径下
|
|
621
|
-
def set_data_in_path(file_name: str = 'config',
|
|
622
|
-
param: str = None,
|
|
623
|
-
file_path: str = '') -> None:
|
|
624
|
-
config_path = file_path + '/' + __CONFIG_PATH
|
|
625
|
-
if not os.path.exists(config_path):
|
|
626
|
-
os.mkdir(config_path)
|
|
627
|
-
file_path = config_path + '/' + file_name + '.json'
|
|
628
|
-
text_file = open(file_path, 'w', encoding='utf-8')
|
|
629
|
-
text_file.write(to_str({} if param is None else param))
|
|
630
|
-
text_file.close()
|
|
631
|
-
|
|
632
|
-
|
|
633
565
|
# 执行命令
|
|
634
566
|
def exec_command(command: str = None) -> None:
|
|
635
567
|
if command is None:
|
upplib/util.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from upplib import *
|
|
2
|
-
from upplib.
|
|
2
|
+
from upplib.file_text import *
|
|
3
3
|
from datetime import datetime, timezone, timedelta
|
|
4
4
|
from typing import Any, Optional, Union, Callable, List
|
|
5
5
|
|
|
@@ -50,8 +50,7 @@ def get_from_txt(file_name: str = '_start_time_end_time_str.txt',
|
|
|
50
50
|
second : 获得时间,在 second 基础上,前后冗余多少秒
|
|
51
51
|
获得日志
|
|
52
52
|
"""
|
|
53
|
-
date_list = to_list_from_txt(file_name)
|
|
54
|
-
date_list = list(filter(lambda x: len(x) > 0 and not str(x).strip().startswith('#'), date_list))
|
|
53
|
+
date_list = to_list_from_txt(file_name, line_ignore_start_with='#')
|
|
55
54
|
if len(date_list) == 0:
|
|
56
55
|
return None, None
|
|
57
56
|
date_time_list = []
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
upplib/__init__.py,sha256=
|
|
1
|
+
upplib/__init__.py,sha256=nWtsWCkm9fxAT0JiJ22xd1kq1WD8tp8gbZanIyy5Wbo,862
|
|
2
2
|
upplib/chart.py,sha256=DEcfhr1HlWdITaPWTVlL0CVSr3GiJTV_bWyOPb1UoyA,27667
|
|
3
3
|
upplib/chart_html.py,sha256=39CTD2LbN7LNN3wtb3n-ojN2r_X7RJMWappPgiLSJG4,23144
|
|
4
4
|
upplib/clean_up_msg.py,sha256=yR4D2fIXOT8z9VpClfhBjVnjhexObgNZDhvPu5v_5Y4,19237
|
|
5
5
|
upplib/common_package.py,sha256=2-u66k4WbZnX6-PUaYy8wsblnz41nvtX4Hwo3J5hjO0,832
|
|
6
|
+
upplib/config_data.py,sha256=y-2S70V0jwXJXxXz2vsqCK--Heay27VnA7MGpO3a40o,2748
|
|
6
7
|
upplib/db.py,sha256=-3ZALQSzP92-zIhye6ckrXIctbHsVmwoLiCVOlTyDyo,7058
|
|
7
|
-
upplib/file.py,sha256
|
|
8
|
-
upplib/file_text.py,sha256=
|
|
8
|
+
upplib/file.py,sha256=-IZ8NJq7iaOG0TZbTjpgZcDFNNR-wC0-78Nyt02PReM,8675
|
|
9
|
+
upplib/file_text.py,sha256=qUQZhjovV1N3oDBX14hbPCuuYeUWALiQ6WGC4z9Ksjg,43074
|
|
9
10
|
upplib/format_data.py,sha256=Qxq-OZ8v6HBRJ-tUcNFem1Imbauk3Y5qJTrAGT0CC4I,10153
|
|
10
11
|
upplib/http_util.py,sha256=8Xya5qpeCKGaglxKnirOlOnbnBU3K52FGV5Y9c8HH9k,16119
|
|
11
|
-
upplib/index.py,sha256=
|
|
12
|
+
upplib/index.py,sha256=8m1aDWEFa7_-hvsIToxFKz2VtxMNVrm1GyrQEbFF6aQ,23190
|
|
12
13
|
upplib/mail.py,sha256=pe1ZZlKsah_TiB_Ag3scgiIQegyOznul2awdHur2m4Y,7550
|
|
13
14
|
upplib/mail_html.py,sha256=W2_WT9WhFykmAFageboJ-6E0dnBHBGMG1vQlBb9__M8,4001
|
|
14
15
|
upplib/markdown.py,sha256=YXh2Rtb5gvZ755Ecr3r5FcMoDtd2YcqtOFHFv92jWOQ,5803
|
|
15
16
|
upplib/multi_thread.py,sha256=zOeWG5HGYIzwqiPvef-4ak5bzorf0S3q6Ht8wPit_M0,2705
|
|
16
17
|
upplib/query_log.py,sha256=m93f8wyZeatVs_PF8O5eyC6U5yJfohg7x6muXPUMOJA,9204
|
|
17
18
|
upplib/redis_tool.py,sha256=I1kOqBwfQWVIOAY-hQaaOn1Zrx8BNlK83u-pk4uHPCA,707
|
|
18
|
-
upplib/util.py,sha256=
|
|
19
|
-
upplib-3.
|
|
20
|
-
upplib-3.
|
|
21
|
-
upplib-3.
|
|
22
|
-
upplib-3.
|
|
23
|
-
upplib-3.
|
|
19
|
+
upplib/util.py,sha256=oCQ84njl96A8RGnMqFl3W-2mLZEqcBmpOrK-GDCTmWk,4633
|
|
20
|
+
upplib-3.3.1.dist-info/licenses/LICENSE,sha256=WI5JtXXhjcqnIcPllDA1ZtuxNnZ515xjElcILo7z28o,1073
|
|
21
|
+
upplib-3.3.1.dist-info/METADATA,sha256=tv1bswKgtakEzfUBL_e1dFMGFN2wdio0tkisRkxKY6k,940
|
|
22
|
+
upplib-3.3.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
23
|
+
upplib-3.3.1.dist-info/top_level.txt,sha256=VwdHDDPP79e1LqtRu5_w30hHB4gT0zlj1weuQYOqFoA,7
|
|
24
|
+
upplib-3.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|