arpakitlib 1.8.283__py3-none-any.whl → 1.8.294__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.

Potentially problematic release.


This version of arpakitlib might be problematic. Click here for more details.

@@ -1,8 +1,10 @@
1
1
  import asyncio
2
2
 
3
+ from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
4
+
3
5
 
4
6
  def __sandbox():
5
- pass
7
+ print(UserDBM.get_sd_property_names())
6
8
 
7
9
 
8
10
  async def __async_sandbox():
@@ -47,6 +47,16 @@ def remove_from_list_if_left(*, list_: list[Any], values: list[Any]) -> list[Any
47
47
  return list_
48
48
 
49
49
 
50
+ def remove_from_lists_if_left(
51
+ *,
52
+ lists_: list[list[Any]],
53
+ values: list[Any]
54
+ ):
55
+ for list_ in lists_:
56
+ remove_from_list_if_left(list_=list_, values=values)
57
+ return lists_
58
+
59
+
50
60
  def __example():
51
61
  a = remove_from_list_if_left(
52
62
  list_=[1,2,2,2,2,2,3,3,3,3,3,3],
@@ -73,7 +73,7 @@ class BaseDBM(DeclarativeBase):
73
73
  *,
74
74
  include_pk: bool = True,
75
75
  exclude_names: list[str] | None = None,
76
- exclude_if_have_foreign_keys: bool = False
76
+ exclude_if_have_foreign_keys: bool = False
77
77
  ) -> list[str]:
78
78
  if exclude_names is None:
79
79
  exclude_names = []
@@ -123,7 +123,7 @@ class BaseDBM(DeclarativeBase):
123
123
  include_column_names: bool = True,
124
124
  include_column_pk: bool = True,
125
125
  exclude_column_names: list[str] | None = None,
126
- exclude_column_names_if_have_foreign_keys: bool = False,
126
+ exclude_column_names_if_have_foreign_keys: bool = False,
127
127
 
128
128
  include_relationship_names: bool = True,
129
129
  exclude_relationship_one_to_many: bool = False,
@@ -152,16 +152,26 @@ class BaseDBM(DeclarativeBase):
152
152
  cls,
153
153
  *,
154
154
  prefix: str = "sdp_",
155
- remove_prefix: bool = False
155
+ remove_prefix: bool = False,
156
+ exclude_property_names: list[str] | None = None,
156
157
  ) -> list[str]:
157
- props = [
158
- name
159
- for name, attr in vars(cls).items()
160
- if isinstance(attr, property) and name.startswith(prefix)
161
- ]
162
- if remove_prefix:
163
- return [name[len(prefix):] for name in props]
164
- return props
158
+ exclude_property_names = set(exclude_property_names or [])
159
+ res: list[str] = []
160
+
161
+ # идём от потомка к базам, переопределения потомка «побеждают»
162
+ for c in cls.__mro__:
163
+ if c is object:
164
+ continue
165
+ for name, attr in c.__dict__.items():
166
+ if not isinstance(attr, property):
167
+ continue
168
+ if not name.startswith(prefix):
169
+ continue
170
+ if name in exclude_property_names or name in res:
171
+ continue
172
+ res.append(name)
173
+
174
+ return [n[len(prefix):] for n in res] if remove_prefix else res
165
175
 
166
176
  def simple_dict(
167
177
  self,
@@ -0,0 +1,74 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from pathlib import Path
5
+ from typing import Optional
6
+
7
+ LINE_RE = re.compile(r"""
8
+ ^(?P<lead>\s*)
9
+ (?:(?P<export>export)\s+)? # optional 'export '
10
+ (?P<key>[A-Za-z_][A-Za-z0-9_]*?) # KEY
11
+ (?P<eq>\s*=\s*) # equals with any spaces around
12
+ (?P<val>.*) # value (raw, keep as-is)
13
+ $
14
+ """, re.VERBOSE)
15
+
16
+ COMMENT_RE = re.compile(r"^\s*#")
17
+
18
+
19
+ def uppercase_env_keys(*, path: str | Path,
20
+ output: Optional[str | Path] = None,
21
+ backup: bool = False) -> Path:
22
+ """
23
+ Преобразует имена переменных в .env в верхний регистр.
24
+
25
+ :param path: путь к исходному .env
26
+ :param output: путь к файлу вывода. Если None — правит на месте.
27
+ :param backup: делать .bak при in-place
28
+ :return: путь к записанному файлу
29
+ """
30
+ src = Path(path)
31
+ if not src.exists():
32
+ raise FileNotFoundError(src)
33
+
34
+ text = src.read_text(encoding="utf-8-sig").splitlines(keepends=True)
35
+
36
+ seen_upper = set()
37
+ out_lines = []
38
+
39
+ for line in text:
40
+ # комментарии и пустые строки — как есть
41
+ if not line.strip() or COMMENT_RE.match(line):
42
+ out_lines.append(line)
43
+ continue
44
+
45
+ m = LINE_RE.match(line.rstrip("\n"))
46
+ if not m:
47
+ # строки без "=" или нестандартные — не трогаем
48
+ out_lines.append(line)
49
+ continue
50
+
51
+ lead = m.group("lead") or ""
52
+ export_kw = m.group("export") or ""
53
+ key = m.group("key")
54
+ eq = m.group("eq")
55
+ val = m.group("val")
56
+
57
+ key_up = key.upper()
58
+ # аккуратно соберем строку обратно (сохраняя пробелы/формат)
59
+ new_line = f"{lead}{(export_kw + ' ') if export_kw else ''}{key_up}{eq}{val}\n"
60
+ out_lines.append(new_line)
61
+
62
+ seen_upper.add(key_up)
63
+
64
+ # запись
65
+ if output is None:
66
+ if backup:
67
+ bak = src.with_suffix(src.suffix + ".bak")
68
+ bak.write_text("".join(text), encoding="utf-8")
69
+ dst = src
70
+ else:
71
+ dst = Path(output)
72
+
73
+ dst.write_text("".join(out_lines), encoding="utf-8")
74
+ return dst
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arpakitlib
3
- Version: 1.8.283
3
+ Version: 1.8.294
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -35,7 +35,6 @@ Requires-Dist: gunicorn (>=23.0.0,<24.0.0)
35
35
  Requires-Dist: itsdangerous (>=2.2.0,<3.0.0)
36
36
  Requires-Dist: jupyter (>=1.1.1,<2.0.0)
37
37
  Requires-Dist: markdown (>=3.7,<4.0)
38
- Requires-Dist: matplotlib (>=3.10.0,<4.0.0)
39
38
  Requires-Dist: openai (>=2.2.0,<3.0.0)
40
39
  Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
41
40
  Requires-Dist: orjson (>=3.10.15,<4.0.0)
@@ -43,6 +42,7 @@ Requires-Dist: pandas (>=2.2.3,<3.0.0)
43
42
  Requires-Dist: paramiko (>=4.0.0,<5.0.0)
44
43
  Requires-Dist: pika (>=1.3.2,<2.0.0)
45
44
  Requires-Dist: poetry (>=2.0.1,<3.0.0)
45
+ Requires-Dist: poetry-plugin-export (>=1.9.0)
46
46
  Requires-Dist: psycopg2-binary (>=2.9.10,<3.0.0)
47
47
  Requires-Dist: pulp (>=2.9.0,<3.0.0)
48
48
  Requires-Dist: pydantic (>=2.10.5,<3.0.0)
@@ -69,7 +69,7 @@ Requires-Dist: xlsxwriter (>=3.2.5,<4.0.0)
69
69
  Project-URL: Documentation, https://github.com/ARPAKIT-Company/arpakitlib
70
70
  Project-URL: Homepage, https://github.com/ARPAKIT-Company/arpakitlib
71
71
  Project-URL: Repository, https://github.com/ARPAKIT-Company/arpakitlib
72
- Project-URL: arpakit_company_site, https://arpakit.com/
72
+ Project-URL: arpakit_company_site, https://arpakit.com
73
73
  Project-URL: telegram_channel, https://t.me/arpakitlib
74
74
  Description-Content-Type: text/markdown
75
75
 
@@ -236,7 +236,7 @@ arpakitlib/_arpakit_project_template_v_5/project/resource/templates/healthcheck.
236
236
  arpakitlib/_arpakit_project_template_v_5/project/resource/templates/simple_email.html,sha256=NNfrRzQFrymBSjWZdO-nkNSKk68hyPP9XgvQXpNQI4I,1112
237
237
  arpakitlib/_arpakit_project_template_v_5/project/sandbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
238
238
  arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_1.py,sha256=xKSp7tIBu3Ffp_kgJkwVtdam3BcoFZ44JPVHoRRaP0E,163
239
- arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_2.py,sha256=xKSp7tIBu3Ffp_kgJkwVtdam3BcoFZ44JPVHoRRaP0E,163
239
+ arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_2.py,sha256=ASf9gG8xIhMIW6yH218C_NF4WITND9UgTJ07FlR4o5Y,258
240
240
  arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_3.py,sha256=CIv4vQfBLhlIh92fiLhmyTXSZXjDovxTFZtUBDnWyFY,427
241
241
  arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_4.py,sha256=Oalf7__usi-AkxjoeKQgrbdvaK7Mevh6i92u0Upoq50,460
242
242
  arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_5.py,sha256=xKSp7tIBu3Ffp_kgJkwVtdam3BcoFZ44JPVHoRRaP0E,163
@@ -408,7 +408,7 @@ arpakitlib/ar_json_db_util.py,sha256=5nELpAY1_5_iTN4nMcutQtJQ5Nt52-xiKELxEH65RkY
408
408
  arpakitlib/ar_json_util.py,sha256=jnVfpQ6QSDq8NgIlh_6ZzXDveOiybr7QSQkXutE7d2s,2676
409
409
  arpakitlib/ar_jwt_util.py,sha256=Rhm4ywoTAn6yOV8NLjDASfAtAtheROxxDP40G3XjnuQ,761
410
410
  arpakitlib/ar_list_of_dicts_to_xlsx.py,sha256=MyjEl4Jl4beLVZqLVQMMv0-XDtBD3Xh4Z_ZPDJeFu04,745
411
- arpakitlib/ar_list_util.py,sha256=Ol0fVN8BGTg3wT8PN-fUOQwAchqsc0AWLjySCY8zVTg,1578
411
+ arpakitlib/ar_list_util.py,sha256=xaUk2BnLvDMP5HDh_GFfH-nIXCg-f8NsrrUKXRcVUsU,1788
412
412
  arpakitlib/ar_logging_util.py,sha256=CvKvaKqsl1UucgwL28cWadK9f6t5vaF2DmwbZMa8FmU,1681
413
413
  arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
414
414
  arpakitlib/ar_need_type_util.py,sha256=XmY1kswz8j9oo5f9CxRu0_zgfvxWrXPYKOj6MM04sGk,2604
@@ -428,11 +428,12 @@ arpakitlib/ar_settings_util.py,sha256=Y5wi_cmsjDjfJpM0VJHjbo0NoVPKfypKaD1USowwDt
428
428
  arpakitlib/ar_sleep_util.py,sha256=ggaj7ML6QK_ADsHMcyu6GUmUpQ_9B9n-SKYH17h-9lM,1045
429
429
  arpakitlib/ar_sqladmin_util.py,sha256=SEoaowAPF3lhxPsNjwmOymNJ55Ty9rmzvsDm7gD5Ceo,861
430
430
  arpakitlib/ar_sqlalchemy_drop_check_constraints.py,sha256=XEqnMrIwSYasW_UOJ8xU-JhsVrcYeyehalFuSvmJMak,3518
431
- arpakitlib/ar_sqlalchemy_util.py,sha256=nUDCxhu0l8P0eBCdLyXej3_yLvBlB3LrGhMWzAekm5E,16532
431
+ arpakitlib/ar_sqlalchemy_util.py,sha256=vWNCzFv13YsGRZaemkNI1_BF__4Z1_Vqm-gqQL1PRrQ,17034
432
432
  arpakitlib/ar_str_util.py,sha256=2lGpnXDf2h1cBZpVf5i1tX_HCv5iBd6IGnrCw4QWWlY,4350
433
433
  arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,4049
434
- arpakitlib-1.8.283.dist-info/METADATA,sha256=_yX8P8IL_S2i2w3m1m_YBEGV24OW8Q-gU2g77gWrnJs,4060
435
- arpakitlib-1.8.283.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
436
- arpakitlib-1.8.283.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
437
- arpakitlib-1.8.283.dist-info/licenses/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
438
- arpakitlib-1.8.283.dist-info/RECORD,,
434
+ arpakitlib/uppercase_env_keys.py,sha256=UFHLGIR70UB02eD7IAIBrZIbycwWCx3OP_W4J2cx2Jw,2395
435
+ arpakitlib-1.8.294.dist-info/METADATA,sha256=zuyMTr_yvhK0_nw9UVafNkEGhx2ciC7zvoHnKQUQTKI,4061
436
+ arpakitlib-1.8.294.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
437
+ arpakitlib-1.8.294.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
438
+ arpakitlib-1.8.294.dist-info/licenses/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
439
+ arpakitlib-1.8.294.dist-info/RECORD,,