MainShortcuts2 2.8.2__tar.gz → 2.8.4__tar.gz
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.
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/PKG-INFO +1 -1
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/pyproject.toml +1 -1
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/_module_info.py +1 -1
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/pathlib_ex.py +41 -9
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ms2dat1.py +9 -2
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/sql/_sql_base.py +4 -3
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/README.md +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/__init__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/__main__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/_any2json_regs.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/_ms2app_regs.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/_ms2dat_auto.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/advanced.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/any2json.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/base.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/gigachat.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/github.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/webdav.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/cfg.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/core.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/core_config.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/dict.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/dir.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/__init__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/aiohttp_ex/web/__main__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/datetime_ex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/pil_ex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/psutil_ex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/sqlite_ex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/urlparse_ex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/file.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/gui_scripts/__init__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/gui_scripts/ms2_hash_gen.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/gui_scripts/utils.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/java_ext/__init__.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/java_ext/ms2ext.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/json.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/linux.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/list.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ms2app.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ms2hash.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/path.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/proc.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/regex.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/special_chars.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/sql/mysql.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/sql/postgresql.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/sql/sqlite.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/str.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/term.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/types.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/utils.py +0 -0
- {mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/win.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
name = 'mainshortcuts2'
|
|
2
|
-
version = '2.8.
|
|
2
|
+
version = '2.8.4'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import pathlib
|
|
3
3
|
import shutil
|
|
4
|
+
import typing
|
|
4
5
|
from MainShortcuts2 import ms
|
|
5
6
|
from os import fspath
|
|
6
7
|
from stat import S_ISDIR, S_ISREG
|
|
@@ -12,7 +13,7 @@ class Path(pathlib.Path):
|
|
|
12
13
|
"""Объект `ms.path.Path`"""
|
|
13
14
|
return ms.path.Path(self)
|
|
14
15
|
|
|
15
|
-
def size(self, recursive=False, **walk_kw):
|
|
16
|
+
def size(self, recursive=False, **walk_kw) -> int:
|
|
16
17
|
"""Вычислить размер файла/папки"""
|
|
17
18
|
st = self.stat()
|
|
18
19
|
if S_ISREG(st.st_mode):
|
|
@@ -56,7 +57,7 @@ class Path(pathlib.Path):
|
|
|
56
57
|
def _get_write_path(self):
|
|
57
58
|
"""tmp,real"""
|
|
58
59
|
real = self.resolve()
|
|
59
|
-
tmp = real
|
|
60
|
+
tmp = real.with_name(self.name + ".tmp" + ms.utils.randstr(4))
|
|
60
61
|
while tmp.exists():
|
|
61
62
|
tmp = real.with_name(self.name + ".tmp" + ms.utils.randstr(4))
|
|
62
63
|
return tmp, real
|
|
@@ -71,18 +72,24 @@ class Path(pathlib.Path):
|
|
|
71
72
|
kw.setdefault("encoding", "utf-8")
|
|
72
73
|
"""Записать текст в файл"""
|
|
73
74
|
tmp, real = self._get_write_path()
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
try:
|
|
76
|
+
with tmp.open("w", **kw) as f:
|
|
77
|
+
result = f.write(data)
|
|
77
78
|
tmp.replace(real)
|
|
79
|
+
except:
|
|
80
|
+
tmp.unlink(True)
|
|
81
|
+
raise
|
|
78
82
|
return result
|
|
79
83
|
|
|
80
|
-
def write_bytes(self, data, **kw) -> int:
|
|
84
|
+
def write_bytes(self, data: bytes, **kw) -> int:
|
|
81
85
|
tmp, real = self._get_write_path()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
try:
|
|
87
|
+
with tmp.open("wb", **kw) as f:
|
|
88
|
+
result = f.write(data)
|
|
85
89
|
tmp.replace(real)
|
|
90
|
+
except:
|
|
91
|
+
tmp.unlink(True)
|
|
92
|
+
raise
|
|
86
93
|
return result
|
|
87
94
|
|
|
88
95
|
def read_json(self, **kw):
|
|
@@ -140,3 +147,28 @@ class Path(pathlib.Path):
|
|
|
140
147
|
yield from [os.path.join(root, i) for i in filenames]
|
|
141
148
|
else:
|
|
142
149
|
yield from os.listdir(self)
|
|
150
|
+
if not typing.TYPE_CHECKING:
|
|
151
|
+
def samefile(self, other_path):
|
|
152
|
+
"""Добавление проверки пути к файлу, чтобы не выполнять stat лишний раз"""
|
|
153
|
+
if os.fspath(self) == os.fspath(other_path):
|
|
154
|
+
return True
|
|
155
|
+
return super().samefile(other_path)
|
|
156
|
+
|
|
157
|
+
def samestat(self, st2: os.stat_result):
|
|
158
|
+
"""Аналогично `.samefile`, но принимает `stat_result` вместо пути"""
|
|
159
|
+
st1 = self.stat()
|
|
160
|
+
return st1.st_dev == st2.st_dev and st1.st_ino == st2.st_ino
|
|
161
|
+
|
|
162
|
+
def write_ms2dat(self, data, **kw):
|
|
163
|
+
"""Сохранить данные в последней версии формата MS2Dat"""
|
|
164
|
+
ms.ms2dat.write_file(data, self, **kw)
|
|
165
|
+
|
|
166
|
+
def write_ms2dat_v1(self, data, ms2dat_inst=None, **kw):
|
|
167
|
+
"""Сохранить данные в формате MS2Dat v1"""
|
|
168
|
+
if ms2dat_inst is None:
|
|
169
|
+
ms2dat_inst = ms.ms2dat_v1.inst
|
|
170
|
+
ms2dat_inst.write_file(data, self, **kw)
|
|
171
|
+
|
|
172
|
+
def read_ms2dat(self, **kw):
|
|
173
|
+
"""Прочитать данные в формате MS2Dat"""
|
|
174
|
+
ms.ms2dat.read_file(self, **kw)
|
|
@@ -6,6 +6,7 @@ import struct
|
|
|
6
6
|
import typing
|
|
7
7
|
import uuid
|
|
8
8
|
from io import BytesIO
|
|
9
|
+
from MainShortcuts2.ex.pathlib_ex import Path
|
|
9
10
|
from MainShortcuts2.utils import int_size_unsigned
|
|
10
11
|
HASH_NAMES = None, "sha256", "sha3-256", "sha512"
|
|
11
12
|
HASH_SIZES = 0, 32, 32, 64
|
|
@@ -516,8 +517,14 @@ class MS2Dat1:
|
|
|
516
517
|
|
|
517
518
|
def write_file(self, obj, path, **kw):
|
|
518
519
|
"""Сохранить объект в локальный файл"""
|
|
519
|
-
|
|
520
|
-
|
|
520
|
+
tmp, real = Path(path)._get_write_path()
|
|
521
|
+
try:
|
|
522
|
+
with tmp.open("wb") as f:
|
|
523
|
+
self.dump(obj, f, **kw)
|
|
524
|
+
tmp.replace(real)
|
|
525
|
+
except:
|
|
526
|
+
tmp.unlink(True)
|
|
527
|
+
raise
|
|
521
528
|
|
|
522
529
|
|
|
523
530
|
class MS2Dat1EncryptExample(MS2Dat1):
|
|
@@ -101,11 +101,12 @@ class ObjectBase:
|
|
|
101
101
|
|
|
102
102
|
TABLE_NAME = str | ObjectBase | type[ObjectBase]
|
|
103
103
|
gen_uuid = uuid_module.uuid4
|
|
104
|
-
if not typing.TYPE_CHECKING:
|
|
105
|
-
for i in
|
|
104
|
+
if not typing.TYPE_CHECKING:
|
|
105
|
+
for i in (8, 7):
|
|
106
106
|
j = f"uuid{i}"
|
|
107
|
-
if
|
|
107
|
+
if hasattr(uuid_module, j):
|
|
108
108
|
gen_uuid = getattr(uuid_module, j)
|
|
109
|
+
break
|
|
109
110
|
|
|
110
111
|
|
|
111
112
|
class UuidObjectBase(ObjectBase):
|
|
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
|
{mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt
RENAMED
|
File without changes
|
{mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py
RENAMED
|
File without changes
|
{mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/ex/aiohttp_ex/web/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mainshortcuts2-2.8.2 → mainshortcuts2-2.8.4}/src/MainShortcuts2/gui_scripts/ms2_hash_gen.py
RENAMED
|
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
|