MainShortcuts2 2.9.0__tar.gz → 2.9.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.9.0 → mainshortcuts2-2.9.2}/PKG-INFO +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/pyproject.toml +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/_module_info.py +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/base.py +19 -20
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/sqlite_ex.py +5 -3
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/sql/mysql.py +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/sql/postgresql.py +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/sql/sqlite.py +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/README.md +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/__main__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/_any2json_regs.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/_ms2app_regs.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/_ms2dat_auto.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/advanced.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/any2json.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/gigachat.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/github.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/webdav.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/cfg.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/core.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/core_config.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/dict.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/dir.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/aiohttp_ex/web/__main__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/datetime_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/pathlib_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/pil_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/psutil_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/urlparse_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/file.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/gui_scripts/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/gui_scripts/ms2_hash_gen.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/gui_scripts/utils.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/java_ext/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/java_ext/ms2ext.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/json.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/linux.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/list.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ms2app.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ms2dat1.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ms2dat1crypto.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ms2hash.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/path.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/proc.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/regex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/special_chars.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/sql/_sql_base.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/str.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/term.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/types.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/utils.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/win.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
name = 'mainshortcuts2'
|
|
2
|
-
version = '2.9.
|
|
2
|
+
version = '2.9.2'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import requests
|
|
2
2
|
import requests.auth
|
|
3
|
+
from functools import cached_property
|
|
3
4
|
from MainShortcuts2 import ms
|
|
4
5
|
USER_AGENTS: dict[str, str] = {}
|
|
5
6
|
USER_AGENTS["Android"] = "Mozilla/5.0 (Linux; Android 13; K) Chrome/128.0.6613.146"
|
|
@@ -26,7 +27,6 @@ def setdefattr(obj, attr, value):
|
|
|
26
27
|
class BaseClient(ms.ObjectBase):
|
|
27
28
|
"""Базовый клиент для HTTP API"""
|
|
28
29
|
_enable_cookies: bool
|
|
29
|
-
_http: requests.Session
|
|
30
30
|
_url_data: dict[str, str]
|
|
31
31
|
_url: str
|
|
32
32
|
cache: "CacheStorage"
|
|
@@ -35,11 +35,12 @@ class BaseClient(ms.ObjectBase):
|
|
|
35
35
|
self._init(**kw)
|
|
36
36
|
|
|
37
37
|
def _init(self, session: requests.Session = None):
|
|
38
|
-
setdefattr(self, "_http", session)
|
|
39
38
|
setdefattr(self, "_enable_cookies", False)
|
|
40
39
|
setdefattr(self, "_url_data", {})
|
|
41
40
|
setdefattr(self, "_url", "https://example.com/api/{method}")
|
|
42
41
|
setdefattr(self, "cache", CacheStorage())
|
|
42
|
+
if session:
|
|
43
|
+
self.__dict__["http"] = session
|
|
43
44
|
|
|
44
45
|
def __enter__(self):
|
|
45
46
|
return self
|
|
@@ -64,12 +65,10 @@ class BaseClient(ms.ObjectBase):
|
|
|
64
65
|
def _params(self):
|
|
65
66
|
return self.http.params
|
|
66
67
|
|
|
67
|
-
@
|
|
68
|
-
def http(self)
|
|
68
|
+
@cached_property
|
|
69
|
+
def http(self):
|
|
69
70
|
"""HTTP сессия"""
|
|
70
|
-
|
|
71
|
-
self._http = requests.Session()
|
|
72
|
-
return self._http
|
|
71
|
+
return requests.Session()
|
|
73
72
|
|
|
74
73
|
def _request(self, http_method: str, api_method: str, *, raise_for_status: bool = True, url_data: dict[str, str] = None, **kw):
|
|
75
74
|
_url_data = self._url_data.copy()
|
|
@@ -83,26 +82,18 @@ class BaseClient(ms.ObjectBase):
|
|
|
83
82
|
result.raise_for_status()
|
|
84
83
|
return result
|
|
85
84
|
|
|
86
|
-
def request(self, httpm, apim, **kw)
|
|
85
|
+
def request(self, httpm: str, apim: str, **kw):
|
|
87
86
|
"""Отправить запрос к API"""
|
|
88
87
|
return self._request(httpm, apim, **kw)
|
|
89
88
|
|
|
90
89
|
|
|
91
|
-
class Base(BaseClient):
|
|
92
|
-
"""Устаревший класс, используйте BaseClient!"""
|
|
93
|
-
def __init_subclass__(cls, **kw):
|
|
94
|
-
from warnings import warn
|
|
95
|
-
warn("Class 'Base' renamed 'BaseClient' starting with version 2.4.6", DeprecationWarning)
|
|
96
|
-
return BaseClient.__init_subclass__(**kw)
|
|
97
|
-
|
|
98
|
-
|
|
99
90
|
class BasicAuthClient(BaseClient):
|
|
100
91
|
"""API клиент для авторизации `HTTP Basic`"""
|
|
101
92
|
|
|
102
|
-
def _request(self, http_method: str, api_method: str, **kw)
|
|
93
|
+
def _request(self, http_method: str, api_method: str, **kw):
|
|
103
94
|
if self._headers.get("Authorization") is None:
|
|
104
95
|
auth_basic(None, None, client=self)
|
|
105
|
-
return
|
|
96
|
+
return super()._request(http_method, api_method, **kw)
|
|
106
97
|
|
|
107
98
|
@property
|
|
108
99
|
def username(self) -> str:
|
|
@@ -127,9 +118,12 @@ class BasicAuthClient(BaseClient):
|
|
|
127
118
|
|
|
128
119
|
class OfflineObjectBase(ms.ObjectBase):
|
|
129
120
|
"""API объект из словаря"""
|
|
121
|
+
_set_by_annotations = False
|
|
130
122
|
|
|
131
123
|
def __init__(self, raw: dict, *args, **kwargs):
|
|
132
124
|
self.raw = raw
|
|
125
|
+
if self._set_by_annotations:
|
|
126
|
+
_set_annotations(self)
|
|
133
127
|
self._init(*args, **kwargs)
|
|
134
128
|
|
|
135
129
|
def __getitem__(self, k):
|
|
@@ -144,8 +138,13 @@ class ObjectBase(OfflineObjectBase):
|
|
|
144
138
|
|
|
145
139
|
def __init__(self, client: BaseClient, raw: dict, *args, **kwargs):
|
|
146
140
|
self.client = client.client if isinstance(client, ObjectBase) else client
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
super().__init__(raw, *args, **kwargs)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _set_annotations(obj: OfflineObjectBase):
|
|
145
|
+
for i in type(obj).__annotations__:
|
|
146
|
+
if not (i.startswith("_") or hasattr(obj, i)):
|
|
147
|
+
setattr(obj, i, obj[i])
|
|
149
148
|
|
|
150
149
|
|
|
151
150
|
class CacheStorage(dict):
|
|
@@ -37,9 +37,11 @@ def make_insert_sql(table: str, values: dict, modifier=""):
|
|
|
37
37
|
return f"INSERT {modifier}INTO {table} ({keys}) VALUES ({inserts});", list(values.values())
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def make_select_sql(table: str, columns: list[str], where: dict):
|
|
40
|
+
def make_select_sql(table: str, columns: str | list[str], where: dict):
|
|
41
41
|
text, params = make_where_string(where)
|
|
42
|
-
|
|
42
|
+
if not isinstance(columns, str):
|
|
43
|
+
columns = ','.join(columns)
|
|
44
|
+
return f"SELECT {columns} FROM {table} WHERE {text};", params
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
def make_update_sql(table: str, values: dict, where: dict):
|
|
@@ -84,7 +86,7 @@ class Cursor(sqlite3.Cursor):
|
|
|
84
86
|
def select_fetchone(self, table: str, columns: list[str], where: dict):
|
|
85
87
|
return self.select(table, columns, where).fetchone()
|
|
86
88
|
|
|
87
|
-
def select(self, table: str, columns: list[str], where: dict):
|
|
89
|
+
def select(self, table: str, columns: str | list[str], where: dict):
|
|
88
90
|
"""Выбрать строки из таблицы. Не выполняет `fetch`!"""
|
|
89
91
|
return self.execute(*make_select_sql(table, columns, where))
|
|
90
92
|
|
|
@@ -32,7 +32,7 @@ class Database(SyncDatabaseBase):
|
|
|
32
32
|
self.db_path = Path(path)
|
|
33
33
|
self.db_path.parent.any_mkdir()
|
|
34
34
|
self.strict_schema = strict_schema
|
|
35
|
-
|
|
35
|
+
super().__init__(**kw)
|
|
36
36
|
if TYPE_CHECKING:
|
|
37
37
|
def cursor(self) -> Cursor:
|
|
38
38
|
return super().cursor()
|
|
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.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt
RENAMED
|
File without changes
|
{mainshortcuts2-2.9.0 → mainshortcuts2-2.9.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
|
{mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py
RENAMED
|
File without changes
|
{mainshortcuts2-2.9.0 → mainshortcuts2-2.9.2}/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.9.0 → mainshortcuts2-2.9.2}/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
|