MainShortcuts2 2.3.1__tar.gz → 2.3.2__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.3.1 → mainshortcuts2-2.3.2}/PKG-INFO +1 -1
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/pyproject.toml +3 -1
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/__main__.py +55 -1
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/_module_info.py +1 -1
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/utils.py +2 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/README.md +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/__init__.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/advanced.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/api/base.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/api/gigachat.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/cfg.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/core.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/dict.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/dir.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/file.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/json.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/list.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/path.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/proc.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/regex.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/special_chars.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/str.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/term.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/types.py +0 -0
- {mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/win.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
|
-
version = "2.3.
|
|
2
|
+
version = "2.3.2"
|
|
3
3
|
name = "MainShortcuts2"
|
|
4
4
|
description = "Сокращение и улучшение функций + консольные утилиты"
|
|
5
5
|
authors = [ "MainPlay TG <xbox.roman6666666666@gmail.com>",]
|
|
@@ -10,6 +10,8 @@ packages = [
|
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
[tool.poetry.scripts]
|
|
13
|
+
ms2-hash_check = "MainShortcuts2.__main__:hash_check"
|
|
14
|
+
ms2-hash_gen = "MainShortcuts2.__main__:hash_gen"
|
|
13
15
|
ms2-import_example = "MainShortcuts2.__main__:import_example"
|
|
14
16
|
nano-json = "MainShortcuts2.__main__:nano_json"
|
|
15
17
|
nginx-reload = "MainShortcuts2.__main__:nginx_reload"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import sys
|
|
3
3
|
from MainShortcuts2 import ms
|
|
4
|
+
HASH_SUFFIX = ".MS2_hash"
|
|
5
|
+
HASH_TYPES = ["sha1", "sha256", "sha512"]
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
def import_example():
|
|
@@ -21,7 +23,7 @@ def nano_json():
|
|
|
21
23
|
if args.nano_help:
|
|
22
24
|
return subprocess.call(["nano", "--help"])
|
|
23
25
|
nano_args = ["nano"]
|
|
24
|
-
if
|
|
26
|
+
if args.rcfile:
|
|
25
27
|
nano_args += ["--rcfile", args.rcfile]
|
|
26
28
|
nano_args += args.files
|
|
27
29
|
for i in args.files:
|
|
@@ -72,3 +74,55 @@ def nginx_restart():
|
|
|
72
74
|
if code != 0:
|
|
73
75
|
sys.exit(code)
|
|
74
76
|
sys.exit(subprocess.call(["systemctl", "restart", "nginx"]))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def hash_gen():
|
|
80
|
+
import os
|
|
81
|
+
import hashlib
|
|
82
|
+
argp = argparse.ArgumentParser("ms2-hash-gen", description="создание контрольной суммы для файла")
|
|
83
|
+
argp.add_argument("files", nargs="+", help="пути к файлам")
|
|
84
|
+
argp.add_argument("-t", "--type", choices=HASH_TYPES, default="sha512", help="тип контрольной суммы")
|
|
85
|
+
args = argp.parse_args()
|
|
86
|
+
data = {}
|
|
87
|
+
data["format"] = "MainShortcuts2_hash_v1"
|
|
88
|
+
data["file"] = {}
|
|
89
|
+
data["hash"] = {}
|
|
90
|
+
data["hash"]["type"] = args.type
|
|
91
|
+
Hash = getattr(hashlib, args.type)
|
|
92
|
+
for file in args.files:
|
|
93
|
+
hash = Hash()
|
|
94
|
+
data["file"]["size"] = os.path.getsize(file)
|
|
95
|
+
with open(file, "rb") as f:
|
|
96
|
+
for chunk in f:
|
|
97
|
+
hash.update(chunk)
|
|
98
|
+
data["hash"]["hex"] = hash.hexdigest()
|
|
99
|
+
ms.json.write(file + HASH_SUFFIX, data)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def hash_check()
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
import hashlib
|
|
106
|
+
import os
|
|
107
|
+
import shlex
|
|
108
|
+
argp = argparse.ArgumentParser("ms2-hash-check", description="проверка размера и контрольной суммы файла")
|
|
109
|
+
argp.add_argument("files", nargs="+", help="пути к файлам")
|
|
110
|
+
args = argp.parse_args()
|
|
111
|
+
for file in args.files:
|
|
112
|
+
if file.lower().endswith(HASH_SUFFIX.lower()):
|
|
113
|
+
file = file[:0 - len(HASH_SUFFIX)]
|
|
114
|
+
if not os.path.exists(file + HASH_SUFFIX):
|
|
115
|
+
print("Ошибка: не найден файл " + shlex.quote(file + HASH_SUFFIX), file=sys.stderr)
|
|
116
|
+
continue
|
|
117
|
+
data = ms.json.read(file + HASH_SUFFIX)
|
|
118
|
+
if data["file"]["size"] != os.path.getsize(file):
|
|
119
|
+
print("Ошибка: размер файла " + shlex.quote(file) + " не совпадает")
|
|
120
|
+
continue
|
|
121
|
+
hash = getattr(hashlib, data["hash"]["type"])()
|
|
122
|
+
with open(file, "rb") as f:
|
|
123
|
+
for chunk in f:
|
|
124
|
+
hash.update(chunk)
|
|
125
|
+
if data["hash"]["hex"] == hash.hexdigest():
|
|
126
|
+
print("Успех: файл " + shlex.quote(file) + " не изменён")
|
|
127
|
+
else:
|
|
128
|
+
print("Ошибка: файл " + shlex.quote(file) + " изменён")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
name = "MainShortcuts2"
|
|
2
|
-
version = "2.3.
|
|
2
|
+
version = "2.3.2"
|
|
@@ -463,6 +463,8 @@ def check_programs(*progs: str, raise_error: bool = True) -> list[str]:
|
|
|
463
463
|
failed.sort()
|
|
464
464
|
if raise_error:
|
|
465
465
|
if len(failed) > 0:
|
|
466
|
+
if len(failed) == 1:
|
|
467
|
+
raise OSError("Failed to find program " + failed[0] + " in $PATH")
|
|
466
468
|
raise OSError("Failed to find programs " + (", ".join(failed)) + " in $PATH")
|
|
467
469
|
return failed
|
|
468
470
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt
RENAMED
|
File without changes
|
{mainshortcuts2-2.3.1 → mainshortcuts2-2.3.2}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|