reykit 1.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.
- reykit/__init__.py +41 -0
- reykit/rall.py +33 -0
- reykit/rcomm.py +431 -0
- reykit/rdata.py +395 -0
- reykit/rdll/__init__.py +17 -0
- reykit/rdll/rdll_inject.py +41 -0
- reykit/rdll/rdll_inject_core.py +202 -0
- reykit/remail.py +276 -0
- reykit/rexception.py +339 -0
- reykit/rimage.py +261 -0
- reykit/rlog.py +1061 -0
- reykit/rmonkey.py +341 -0
- reykit/rmultitask.py +871 -0
- reykit/rnumber.py +161 -0
- reykit/ros.py +1917 -0
- reykit/rrandom.py +351 -0
- reykit/rregex.py +293 -0
- reykit/rschedule.py +272 -0
- reykit/rstdout.py +356 -0
- reykit/rsystem.py +1180 -0
- reykit/rtable.py +511 -0
- reykit/rtext.py +458 -0
- reykit/rtime.py +678 -0
- reykit/rtype.py +106 -0
- reykit/rwrap.py +613 -0
- reykit/rzip.py +137 -0
- reykit-1.0.0.dist-info/METADATA +29 -0
- reykit-1.0.0.dist-info/RECORD +30 -0
- reykit-1.0.0.dist-info/WHEEL +5 -0
- reykit-1.0.0.dist-info/top_level.txt +1 -0
reykit/rzip.py
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# !/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
"""
|
5
|
+
@Time : 2023-01-19 19:23:57
|
6
|
+
@Author : Rey
|
7
|
+
@Contact : reyxbo@163.com
|
8
|
+
@Explain : File compress methods.
|
9
|
+
"""
|
10
|
+
|
11
|
+
|
12
|
+
from __future__ import annotations
|
13
|
+
from typing import Optional
|
14
|
+
from zipfile import ZipFile, is_zipfile, ZIP_DEFLATED
|
15
|
+
from os import getcwd as os_getcwd, walk as os_walk
|
16
|
+
from os.path import join as os_join, isfile as os_isfile
|
17
|
+
|
18
|
+
from .ros import RFile, RFolder
|
19
|
+
|
20
|
+
|
21
|
+
__all__ = (
|
22
|
+
'compress',
|
23
|
+
'decompress',
|
24
|
+
'zip'
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
def compress(
|
29
|
+
obj_path: str,
|
30
|
+
build_dir: Optional[str] = None,
|
31
|
+
overwrite: bool = True
|
32
|
+
) -> None:
|
33
|
+
"""
|
34
|
+
Compress file or folder.
|
35
|
+
|
36
|
+
Parameters
|
37
|
+
----------
|
38
|
+
obj_path : File or folder path.
|
39
|
+
build_dir : Build directory.
|
40
|
+
- `None`: Work directory.
|
41
|
+
- `str`: Use this value.
|
42
|
+
overwrite : Whether to overwrite.
|
43
|
+
"""
|
44
|
+
|
45
|
+
# Get parameter.
|
46
|
+
build_dir = RFolder(build_dir).path
|
47
|
+
if overwrite:
|
48
|
+
mode = 'w'
|
49
|
+
else:
|
50
|
+
mode = 'x'
|
51
|
+
is_file = os_isfile(obj_path)
|
52
|
+
if is_file:
|
53
|
+
rfile = RFile(obj_path)
|
54
|
+
obj_name = rfile.name_suffix
|
55
|
+
else:
|
56
|
+
rfolder = RFolder(obj_path)
|
57
|
+
obj_name = rfolder.name
|
58
|
+
build_name = obj_name + '.zip'
|
59
|
+
build_path = os_join(build_dir, build_name)
|
60
|
+
|
61
|
+
# Compress.
|
62
|
+
with ZipFile(build_path, mode, ZIP_DEFLATED) as zip_file:
|
63
|
+
|
64
|
+
## File.
|
65
|
+
if is_file:
|
66
|
+
zip_file.write(rfile.path, rfile.name_suffix)
|
67
|
+
|
68
|
+
## Folder.
|
69
|
+
else:
|
70
|
+
dir_path_len = len(rfolder.path)
|
71
|
+
dirs = os_walk(rfolder.path)
|
72
|
+
for folder_name, sub_folders_name, files_name in dirs:
|
73
|
+
for sub_folder_name in sub_folders_name:
|
74
|
+
sub_folder_path = os_join(folder_name, sub_folder_name)
|
75
|
+
zip_path = sub_folder_path[dir_path_len:]
|
76
|
+
zip_file.write(sub_folder_path, zip_path)
|
77
|
+
for file_name in files_name:
|
78
|
+
file_path = os_join(folder_name, file_name)
|
79
|
+
zip_path = file_path[dir_path_len:]
|
80
|
+
zip_file.write(file_path, zip_path)
|
81
|
+
|
82
|
+
|
83
|
+
def decompress(
|
84
|
+
obj_path: str,
|
85
|
+
build_dir: Optional[str] = None,
|
86
|
+
password: Optional[str] = None
|
87
|
+
) -> None:
|
88
|
+
"""
|
89
|
+
Decompress compressed object.
|
90
|
+
|
91
|
+
Parameters
|
92
|
+
----------
|
93
|
+
obj_path : Compressed object path.
|
94
|
+
build_dir : Build directory.
|
95
|
+
- `None`: Work directory.
|
96
|
+
- `str`: Use this value.
|
97
|
+
passwrod : Unzip Password.
|
98
|
+
- `None`: No Unzip Password.
|
99
|
+
- `str`: Use this value.
|
100
|
+
"""
|
101
|
+
|
102
|
+
# Check object whether can be decompress.
|
103
|
+
is_support = is_zipfile(obj_path)
|
104
|
+
if not is_support:
|
105
|
+
raise AssertionError('file format that cannot be decompressed')
|
106
|
+
|
107
|
+
# Handle parameter.
|
108
|
+
build_dir = build_dir or os_getcwd()
|
109
|
+
|
110
|
+
# Decompress.
|
111
|
+
with ZipFile(obj_path) as zip_file:
|
112
|
+
zip_file.extractall(build_dir, pwd=password)
|
113
|
+
|
114
|
+
|
115
|
+
def zip(
|
116
|
+
obj_path: str,
|
117
|
+
build_dir: Optional[str] = None
|
118
|
+
) -> None:
|
119
|
+
"""
|
120
|
+
Automatic judge and compress or decompress object.
|
121
|
+
|
122
|
+
Parameters
|
123
|
+
----------
|
124
|
+
obj_path : File or folder or compressed object path.
|
125
|
+
output_path : Build directory.
|
126
|
+
- `None`: Work directory.
|
127
|
+
- `str`: Use this value.
|
128
|
+
"""
|
129
|
+
|
130
|
+
# Judge compress or decompress.
|
131
|
+
is_support = is_zipfile(obj_path)
|
132
|
+
|
133
|
+
# Execute.
|
134
|
+
if is_support:
|
135
|
+
decompress(obj_path, build_dir)
|
136
|
+
else:
|
137
|
+
compress(obj_path, build_dir)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: reykit
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: Rey's kit method set.
|
5
|
+
Home-page: https://github.com/reyxbo/reykit/
|
6
|
+
Author: Rey
|
7
|
+
Author-email: reyxbo@163.com
|
8
|
+
Requires-Dist: aiohttp
|
9
|
+
Requires-Dist: apscheduler
|
10
|
+
Requires-Dist: captcha
|
11
|
+
Requires-Dist: concurrent-log-handler
|
12
|
+
Requires-Dist: filetype
|
13
|
+
Requires-Dist: pandas
|
14
|
+
Requires-Dist: pyzbar
|
15
|
+
Requires-Dist: pdfplumber
|
16
|
+
Requires-Dist: psutil
|
17
|
+
Requires-Dist: pymem
|
18
|
+
Requires-Dist: python-docx
|
19
|
+
Requires-Dist: qrcode
|
20
|
+
Requires-Dist: requests
|
21
|
+
Requires-Dist: tqdm
|
22
|
+
Requires-Dist: urwid
|
23
|
+
Requires-Dist: varname
|
24
|
+
Requires-Dist: Pillow
|
25
|
+
Dynamic: author
|
26
|
+
Dynamic: author-email
|
27
|
+
Dynamic: home-page
|
28
|
+
Dynamic: requires-dist
|
29
|
+
Dynamic: summary
|
@@ -0,0 +1,30 @@
|
|
1
|
+
reykit/__init__.py,sha256=6_scPOFt0urqRmhU5MJwghJHNudgWPhgV6J6fuYibKg,917
|
2
|
+
reykit/rall.py,sha256=mOFwHXZ4-BOkJ5Ptbm6lQc2zwNf_VqcqM6AYYnYPfoo,672
|
3
|
+
reykit/rcomm.py,sha256=_i0hrCB3moZhA3sm2ebg54i9dQ8QjI57ZV2cKm0vxA4,11523
|
4
|
+
reykit/rdata.py,sha256=qmx9yKrfP2frOQjj-34ze8sa1l4sOQXtemkKyrVtKXs,8495
|
5
|
+
reykit/remail.py,sha256=-uSU2yHyFbjs6X9M5Sjb4TMjw4cK8_Bnsmsaos3f0Rs,6860
|
6
|
+
reykit/rexception.py,sha256=sI5EKD5gfsdwApovA4DFnlm_MxmPp7TChNLzGmGvZ9M,8150
|
7
|
+
reykit/rimage.py,sha256=BmNNyhqezN9f40gaE5_rv6B7-v9mYkUwT8n2tfCDfdw,6331
|
8
|
+
reykit/rlog.py,sha256=J-fnY5B3Y2oJOuyHvemy6ltkr8he4spS3iQOADIUg00,26525
|
9
|
+
reykit/rmonkey.py,sha256=s8TdR-_tRRMiR11eCLHCkFAJuAZe7PVIhkR-74Xt8vw,7644
|
10
|
+
reykit/rmultitask.py,sha256=L4_dlIKGV3DrWlID2MDc1Fl-o0kt23l7oYGp4-WJRYU,22057
|
11
|
+
reykit/rnumber.py,sha256=MajaVOVa3_H1lm91cu9HLaLXd9ZsvZYFxXvcklC0LWs,3209
|
12
|
+
reykit/ros.py,sha256=wv1DM2N8MXBwGqBhNUSiDLrvHRK7syibhFwEPGkpxYM,39336
|
13
|
+
reykit/rrandom.py,sha256=uroEvO8oy5zyp8pk2NWcq49ofJxo1_F3H5_W1U_oj5w,8499
|
14
|
+
reykit/rregex.py,sha256=E9BConP7ADYyGVZ5jpxwUmtc_WXFb-I1Zjt6IZSHkIQ,6218
|
15
|
+
reykit/rschedule.py,sha256=TiIFQ0siL20nlhikWfvRGhOdeRbyHQtN6uxFivA2WoI,5852
|
16
|
+
reykit/rstdout.py,sha256=yjCTegPqm2FNIpNGVrmz16Jn2bNncYO1axuANVdTmVQ,9710
|
17
|
+
reykit/rsystem.py,sha256=EbPOKtwtVyXqX4AqKMKPW1cEAixqHAOemaxrlEpT0ZY,29388
|
18
|
+
reykit/rtable.py,sha256=ghsppMMOGkz3boV_CSxpkel5Lfj-ViBziZrpcCoY5YA,12229
|
19
|
+
reykit/rtext.py,sha256=xilQxaMMdaVCBk6rxQb1aI8-j52QVUH5EtTZVMQsa8Q,11108
|
20
|
+
reykit/rtime.py,sha256=2xOGGETwl1Sc3W80a2KiPbI4GsSfIyksTeXgqNOTYVw,17178
|
21
|
+
reykit/rtype.py,sha256=PbfaHjNQTMiZynlz8HwP2K9SS-t91ThMOYBxQIBf9Ug,1975
|
22
|
+
reykit/rwrap.py,sha256=4RdTxT2y7ViyeiWx2fJ54k9ZZT6Bmx5QStIiwEHB6rY,15320
|
23
|
+
reykit/rzip.py,sha256=HTrxyb4e6f38eOPFIXsdbcEwr7FQSqnU2MVmVRBYTbg,3563
|
24
|
+
reykit/rdll/__init__.py,sha256=vM9V7wSNno-WH9RrxgHTIgCkQm8LmBFoLFO8z7qovNo,306
|
25
|
+
reykit/rdll/rdll_inject.py,sha256=bETl8tywtN1OiQudbA21u6GwBM_bqVX7jbiisNj_JBg,645
|
26
|
+
reykit/rdll/rdll_inject_core.py,sha256=Trgh_pdJs_Lw-Y-0Kkn8kHr4BnilM9dBKnHnX25T_pM,5092
|
27
|
+
reykit-1.0.0.dist-info/METADATA,sha256=vUTX5EFI5_u-5aksMa9dRmhar7ESZqvIbljey8pbav0,700
|
28
|
+
reykit-1.0.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
29
|
+
reykit-1.0.0.dist-info/top_level.txt,sha256=2hvySInjpVEcpYg-XFCYVU5xB2TWW8RovoDtBDzAqyE,7
|
30
|
+
reykit-1.0.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
reykit
|