xn-auth 0.2.68.dev1__tar.gz → 0.2.68.dev3__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.
Files changed (24) hide show
  1. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/.pre-commit-config.yaml +1 -1
  2. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/PKG-INFO +1 -1
  3. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/models.py +23 -0
  4. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/PKG-INFO +1 -1
  5. xn_auth-0.2.68.dev3/xn_auth.egg-info/scm_version.json +8 -0
  6. xn_auth-0.2.68.dev1/xn_auth.egg-info/scm_version.json +0 -8
  7. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/.env.dist +0 -0
  8. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/.gitignore +0 -0
  9. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/CLAUDE.md +0 -0
  10. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/README.md +0 -0
  11. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/makefile +0 -0
  12. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/pyproject.toml +0 -0
  13. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/setup.cfg +0 -0
  14. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/tests/test_proxy.py +0 -0
  15. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/controller.py +0 -0
  16. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/enums.py +0 -0
  17. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/exceptions.py +0 -0
  18. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/middleware.py +0 -0
  19. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/x_auth/types.py +0 -0
  20. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/SOURCES.txt +0 -0
  21. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/dependency_links.txt +0 -0
  22. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/requires.txt +0 -0
  23. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/scm_file_list.json +0 -0
  24. {xn_auth-0.2.68.dev1 → xn_auth-0.2.68.dev3}/xn_auth.egg-info/top_level.txt +0 -0
@@ -23,7 +23,7 @@ repos:
23
23
 
24
24
  - repo: https://github.com/astral-sh/ruff-pre-commit
25
25
  ### Ruff version.
26
- rev: v0.12.7
26
+ rev: v0.16.4
27
27
  hooks:
28
28
  ### Run the linter.
29
29
  - id: ruff
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-auth
3
- Version: 0.2.68.dev1
3
+ Version: 0.2.68.dev3
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -27,6 +27,7 @@ from tortoise.fields import (
27
27
  CASCADE,
28
28
  Now,
29
29
  )
30
+ from tortoise.exceptions import IntegrityError
30
31
  from tortoise.fields.data import CharEnumFieldInstance
31
32
 
32
33
  from x_auth import types
@@ -103,6 +104,28 @@ class Country(Model):
103
104
 
104
105
  proxies: BackwardFKRelation["Proxy"]
105
106
 
107
+ @classmethod
108
+ async def get_or_create_by_shortcode(cls, code: str, tries: int = 5) -> "Country":
109
+ """Страна по ISO-коду с сайта; незнакомую заводим, как и город: справочник ведёт сайт.
110
+
111
+ Сайт кладёт в карточку код и молчит о названии, поэтому имя ставим тем же кодом. Id
112
+ считаем сами: у country он uint1 и без sequence.
113
+
114
+ Оттого и цикл, а не одна попытка: номер мы берём чтением, и пока считали, соседняя ветка
115
+ успевает занять и его, и сам код — карточки пачки заводят страны разом. Конфликт значит
116
+ «кто-то уже завёл», и после него всё начинается сначала: либо найдётся чужая строка, либо
117
+ возьмётся следующий свободный номер.
118
+ """
119
+ while True:
120
+ if row := await cls.get_or_none(short=code):
121
+ return row
122
+ last = await cls.all().order_by("-id").first()
123
+ try:
124
+ return await cls.create(id=(last.id if last else 0) + 1, short=code, name=code)
125
+ except IntegrityError:
126
+ if (tries := tries - 1) <= 0:
127
+ raise
128
+
106
129
 
107
130
  class Proxy(Model, TsTrait):
108
131
  id: int = CharField(63, primary_key=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-auth
3
- Version: 0.2.68.dev1
3
+ Version: 0.2.68.dev3
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.2.67",
3
+ "distance": 3,
4
+ "node": "g2b35a3bc484114ff116013e9662d1b241cbe6d7f",
5
+ "dirty": false,
6
+ "branch": "main",
7
+ "node_date": "2026-08-25"
8
+ }
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "0.2.67",
3
- "distance": 1,
4
- "node": "gdbf4963c34ccf29752f04494ca9dfb7e368700c2",
5
- "dirty": false,
6
- "branch": "main",
7
- "node_date": "2026-08-17"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes