MainShortcuts2 2.9.0__tar.gz → 2.9.1__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.1}/PKG-INFO +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/pyproject.toml +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/_module_info.py +1 -1
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/base.py +18 -20
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/sqlite_ex.py +5 -3
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/README.md +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/__main__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/_any2json_regs.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/_ms2app_regs.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/_ms2dat_auto.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/advanced.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/any2json.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/gigachat.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/github.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/russian_trusted_sub_ca_pem.crt +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/api/webdav.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/cfg.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/core.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/core_config.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/dict.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/dir.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/aiohttp_ex/web/__main__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/datetime_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/pathlib_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/pil_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/psutil_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ex/urlparse_ex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/file.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/gui_scripts/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/gui_scripts/ms2_hash_gen.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/gui_scripts/utils.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/java_ext/__init__.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/java_ext/ms2ext.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/json.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/linux.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/list.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ms2app.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ms2dat1.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ms2dat1crypto.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/ms2hash.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/path.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/proc.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/regex.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/special_chars.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/sql/_sql_base.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/sql/mysql.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/sql/postgresql.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/sql/sqlite.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/str.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/term.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/types.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/utils.py +0 -0
- {mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/src/MainShortcuts2/win.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
name = 'mainshortcuts2'
|
|
2
|
-
version = '2.9.
|
|
2
|
+
version = '2.9.1'
|
|
@@ -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,7 +35,7 @@ class BaseClient(ms.ObjectBase):
|
|
|
35
35
|
self._init(**kw)
|
|
36
36
|
|
|
37
37
|
def _init(self, session: requests.Session = None):
|
|
38
|
-
|
|
38
|
+
self.__dict__["http"] = session
|
|
39
39
|
setdefattr(self, "_enable_cookies", False)
|
|
40
40
|
setdefattr(self, "_url_data", {})
|
|
41
41
|
setdefattr(self, "_url", "https://example.com/api/{method}")
|
|
@@ -64,12 +64,10 @@ class BaseClient(ms.ObjectBase):
|
|
|
64
64
|
def _params(self):
|
|
65
65
|
return self.http.params
|
|
66
66
|
|
|
67
|
-
@
|
|
68
|
-
def http(self)
|
|
67
|
+
@cached_property
|
|
68
|
+
def http(self):
|
|
69
69
|
"""HTTP сессия"""
|
|
70
|
-
|
|
71
|
-
self._http = requests.Session()
|
|
72
|
-
return self._http
|
|
70
|
+
return requests.Session()
|
|
73
71
|
|
|
74
72
|
def _request(self, http_method: str, api_method: str, *, raise_for_status: bool = True, url_data: dict[str, str] = None, **kw):
|
|
75
73
|
_url_data = self._url_data.copy()
|
|
@@ -83,26 +81,18 @@ class BaseClient(ms.ObjectBase):
|
|
|
83
81
|
result.raise_for_status()
|
|
84
82
|
return result
|
|
85
83
|
|
|
86
|
-
def request(self, httpm, apim, **kw)
|
|
84
|
+
def request(self, httpm: str, apim: str, **kw):
|
|
87
85
|
"""Отправить запрос к API"""
|
|
88
86
|
return self._request(httpm, apim, **kw)
|
|
89
87
|
|
|
90
88
|
|
|
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
89
|
class BasicAuthClient(BaseClient):
|
|
100
90
|
"""API клиент для авторизации `HTTP Basic`"""
|
|
101
91
|
|
|
102
|
-
def _request(self, http_method: str, api_method: str, **kw)
|
|
92
|
+
def _request(self, http_method: str, api_method: str, **kw):
|
|
103
93
|
if self._headers.get("Authorization") is None:
|
|
104
94
|
auth_basic(None, None, client=self)
|
|
105
|
-
return
|
|
95
|
+
return super()._request(http_method, api_method, **kw)
|
|
106
96
|
|
|
107
97
|
@property
|
|
108
98
|
def username(self) -> str:
|
|
@@ -127,9 +117,12 @@ class BasicAuthClient(BaseClient):
|
|
|
127
117
|
|
|
128
118
|
class OfflineObjectBase(ms.ObjectBase):
|
|
129
119
|
"""API объект из словаря"""
|
|
120
|
+
_set_by_annotations = False
|
|
130
121
|
|
|
131
122
|
def __init__(self, raw: dict, *args, **kwargs):
|
|
132
123
|
self.raw = raw
|
|
124
|
+
if self._set_by_annotations:
|
|
125
|
+
_set_annotations(self)
|
|
133
126
|
self._init(*args, **kwargs)
|
|
134
127
|
|
|
135
128
|
def __getitem__(self, k):
|
|
@@ -144,8 +137,13 @@ class ObjectBase(OfflineObjectBase):
|
|
|
144
137
|
|
|
145
138
|
def __init__(self, client: BaseClient, raw: dict, *args, **kwargs):
|
|
146
139
|
self.client = client.client if isinstance(client, ObjectBase) else client
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
super().__init__(raw, *args, **kwargs)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _set_annotations(obj: OfflineObjectBase):
|
|
144
|
+
for i in type(obj).__annotations__:
|
|
145
|
+
if not (i.startswith("_") or hasattr(obj, i)):
|
|
146
|
+
setattr(obj, i, obj[i])
|
|
149
147
|
|
|
150
148
|
|
|
151
149
|
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
|
|
|
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.1}/src/MainShortcuts2/api/russian_trusted_root_ca_pem.crt
RENAMED
|
File without changes
|
{mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/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.1}/src/MainShortcuts2/ex/aiohttp_ex/web/__init__.py
RENAMED
|
File without changes
|
{mainshortcuts2-2.9.0 → mainshortcuts2-2.9.1}/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.1}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|