utkit 0.6.0__tar.gz → 0.8.0__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 (113) hide show
  1. {utkit-0.6.0 → utkit-0.8.0}/PKG-INFO +78 -78
  2. {utkit-0.6.0 → utkit-0.8.0}/README.md +77 -77
  3. {utkit-0.6.0 → utkit-0.8.0}/pyproject.toml +1 -1
  4. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/__init__.py +5 -5
  5. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/api/rate_limit/__init__.py +9 -9
  6. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/api/rate_limit/error.py +4 -4
  7. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/api/rate_limit/middleware.py +4 -4
  8. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/api/schema/query.py +6 -6
  9. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/auth/__init__.py +15 -15
  10. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/cli/__init__.py +52 -52
  11. utkit-0.8.0/src/utkit/communication/mail/smtp.py +82 -0
  12. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/core/logging.py +88 -88
  13. utkit-0.8.0/src/utkit/documentation/.cache/10042715452264249772 +4 -0
  14. utkit-0.8.0/src/utkit/documentation/.cache/10986014347042203044 +4 -0
  15. utkit-0.8.0/src/utkit/documentation/.cache/11038628458439117958 +4 -0
  16. utkit-0.8.0/src/utkit/documentation/.cache/11306067049371264785 +4 -0
  17. utkit-0.8.0/src/utkit/documentation/.cache/13386297405578974681 +4 -0
  18. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/15312684519617069940 +1 -1
  19. utkit-0.8.0/src/utkit/documentation/.cache/15661711846603463071 +207 -0
  20. utkit-0.8.0/src/utkit/documentation/.cache/16166828772222643061 +144 -0
  21. utkit-0.8.0/src/utkit/documentation/.cache/17695336329032716848 +4 -0
  22. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/17985671397626253671 +1 -1
  23. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/2940665334038842907 +1 -1
  24. utkit-0.8.0/src/utkit/documentation/.cache/3226154870166803660 +4 -0
  25. utkit-0.8.0/src/utkit/documentation/.cache/326316130724058699 +208 -0
  26. utkit-0.8.0/src/utkit/documentation/.cache/3476900567878811119 +4 -0
  27. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/3541202890535126406 +1 -1
  28. utkit-0.8.0/src/utkit/documentation/.cache/360188204203718330 +4 -0
  29. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/403326901327389294 +1 -1
  30. utkit-0.8.0/src/utkit/documentation/.cache/5530722400779903482 +4 -0
  31. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/5696925338617156769 +1 -1
  32. utkit-0.8.0/src/utkit/documentation/.cache/5859600648538783245 +369 -0
  33. utkit-0.8.0/src/utkit/documentation/.cache/5974781288462474643 +4 -0
  34. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/5976522500417319979 +1 -1
  35. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/6210600303880993421 +1 -1
  36. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/6916343365748484443 +1 -1
  37. utkit-0.8.0/src/utkit/documentation/.cache/9033698058957892258 +4 -0
  38. utkit-0.8.0/src/utkit/documentation/.cache/9811225078116513287 +4 -0
  39. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.github/workflows/docs.yml +29 -29
  40. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/api/rate-limit.md +120 -120
  41. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/api/schema.md +73 -73
  42. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/auth.md +98 -98
  43. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/communication/mail.md +177 -143
  44. utkit-0.8.0/src/utkit/documentation/docs/core/logging.md +132 -0
  45. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/index.md +207 -207
  46. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/privacy/mask.md +128 -128
  47. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/privacy/security.md +299 -299
  48. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/store/redis.md +187 -187
  49. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/stylesheets/extra.css +15 -15
  50. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/template/render.md +138 -138
  51. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/utils/performance.md +117 -117
  52. utkit-0.8.0/src/utkit/documentation/docs/validators/data.md +380 -0
  53. utkit-0.8.0/src/utkit/documentation/site/404.html +1177 -0
  54. utkit-0.8.0/src/utkit/documentation/site/api/rate-limit/index.html +1607 -0
  55. utkit-0.8.0/src/utkit/documentation/site/api/schema/index.html +1515 -0
  56. utkit-0.8.0/src/utkit/documentation/site/assets/images/favicon.png +0 -0
  57. utkit-0.8.0/src/utkit/documentation/site/assets/javascripts/LICENSE +29 -0
  58. utkit-0.8.0/src/utkit/documentation/site/assets/javascripts/bundle.dbc0afdc.min.js +3 -0
  59. utkit-0.8.0/src/utkit/documentation/site/assets/javascripts/workers/search.e2d2d235.min.js +1 -0
  60. utkit-0.8.0/src/utkit/documentation/site/assets/stylesheets/classic/main.a2001754.min.css +1 -0
  61. utkit-0.8.0/src/utkit/documentation/site/assets/stylesheets/classic/palette.7dc9a0ad.min.css +1 -0
  62. utkit-0.8.0/src/utkit/documentation/site/assets/stylesheets/modern/main.1e981d71.min.css +1 -0
  63. utkit-0.8.0/src/utkit/documentation/site/assets/stylesheets/modern/palette.dfe2e883.min.css +1 -0
  64. utkit-0.8.0/src/utkit/documentation/site/auth/index.html +1505 -0
  65. utkit-0.8.0/src/utkit/documentation/site/communication/mail/index.html +1829 -0
  66. utkit-0.8.0/src/utkit/documentation/site/core/logging/index.html +1673 -0
  67. utkit-0.8.0/src/utkit/documentation/site/images/logo-old.png +0 -0
  68. utkit-0.8.0/src/utkit/documentation/site/images/logo.png +0 -0
  69. utkit-0.8.0/src/utkit/documentation/site/index.html +1941 -0
  70. utkit-0.8.0/src/utkit/documentation/site/privacy/mask/index.html +1672 -0
  71. utkit-0.8.0/src/utkit/documentation/site/privacy/security/index.html +2114 -0
  72. utkit-0.8.0/src/utkit/documentation/site/search.json +1 -0
  73. utkit-0.8.0/src/utkit/documentation/site/sitemap.xml +3 -0
  74. utkit-0.8.0/src/utkit/documentation/site/store/redis/index.html +1801 -0
  75. utkit-0.8.0/src/utkit/documentation/site/stylesheets/extra.css +15 -0
  76. utkit-0.8.0/src/utkit/documentation/site/template/render/index.html +1594 -0
  77. utkit-0.8.0/src/utkit/documentation/site/utils/performance/index.html +1581 -0
  78. utkit-0.8.0/src/utkit/documentation/site/validators/data/index.html +2040 -0
  79. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/zensical.toml +375 -372
  80. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/privacy/mask.py +56 -56
  81. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/privacy/security.py +166 -166
  82. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/store/redis/__init__.py +50 -50
  83. utkit-0.8.0/src/utkit/template/__init__.py +0 -0
  84. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/template/render.py +35 -35
  85. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/utils/performance.py +35 -35
  86. utkit-0.8.0/src/utkit/validators/__init__.py +4 -0
  87. utkit-0.8.0/src/utkit/validators/data.py +98 -0
  88. utkit-0.6.0/src/utkit/communication/mail/smtp.py +0 -63
  89. utkit-0.6.0/src/utkit/documentation/.cache/10042715452264249772 +0 -4
  90. utkit-0.6.0/src/utkit/documentation/.cache/11005013185016532949 +0 -4
  91. utkit-0.6.0/src/utkit/documentation/.cache/11038628458439117958 +0 -4
  92. utkit-0.6.0/src/utkit/documentation/.cache/11306067049371264785 +0 -4
  93. utkit-0.6.0/src/utkit/documentation/.cache/11523282269049922043 +0 -111
  94. utkit-0.6.0/src/utkit/documentation/.cache/13386297405578974681 +0 -4
  95. utkit-0.6.0/src/utkit/documentation/.cache/16166828772222643061 +0 -127
  96. utkit-0.6.0/src/utkit/documentation/.cache/17695336329032716848 +0 -4
  97. utkit-0.6.0/src/utkit/documentation/.cache/326316130724058699 +0 -176
  98. utkit-0.6.0/src/utkit/documentation/.cache/3476900567878811119 +0 -4
  99. utkit-0.6.0/src/utkit/documentation/.cache/360188204203718330 +0 -4
  100. utkit-0.6.0/src/utkit/documentation/.cache/5520961796158849726 +0 -4
  101. utkit-0.6.0/src/utkit/documentation/.cache/5530722400779903482 +0 -4
  102. utkit-0.6.0/src/utkit/documentation/.cache/5974781288462474643 +0 -4
  103. utkit-0.6.0/src/utkit/documentation/.cache/8439994065325268387 +0 -258
  104. utkit-0.6.0/src/utkit/documentation/.cache/9033698058957892258 +0 -4
  105. utkit-0.6.0/src/utkit/documentation/.cache/9811225078116513287 +0 -4
  106. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/communication/__init__.py +0 -0
  107. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/communication/mail/__init__.py +0 -0
  108. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.cache/.gitignore +0 -0
  109. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/.gitignore +0 -0
  110. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/images/logo-old.png +0 -0
  111. {utkit-0.6.0 → utkit-0.8.0}/src/utkit/documentation/docs/images/logo.png +0 -0
  112. /utkit-0.6.0/src/utkit/privacy/__init__.py → /utkit-0.8.0/src/utkit/documentation/site/objects.inv +0 -0
  113. {utkit-0.6.0/src/utkit/template → utkit-0.8.0/src/utkit/privacy}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: utkit
3
- Version: 0.6.0
3
+ Version: 0.8.0
4
4
  Summary: core libraries for development
5
5
  Author: TINS PJ
6
6
  Author-email: TINS PJ <tinspj1997@gmail.com>
@@ -27,80 +27,80 @@ Provides-Extra: standard
27
27
  Provides-Extra: store
28
28
  Description-Content-Type: text/markdown
29
29
 
30
- # utkit
31
-
32
- <div style="text-align: center; margin: 1.5rem 0;">
33
- <img src="https://res.cloudinary.com/daft06bly/image/upload/v1777439163/logo_wussdc.png" alt="utkit" style="height: 100px; width: auto;" />
34
- </div>
35
-
36
- **utkit** is a collection of core libraries for Python development, providing ready-to-use utilities for common tasks such as authentication, email, encryption, caching, rate limiting, and more.
37
-
38
-
39
- - **Author:** TINS P JOSEPH
40
- - **Requires:** Python `>=3.12`
41
- - **License:** MIT
42
- - **PyPI:** [pypi.org/project/utkit](https://pypi.org/project/utkit/)
43
-
44
- ---
45
-
46
- ## Installation
47
-
48
- ```bash
49
- pip install utkit
50
- ```
51
-
52
- Or with [uv](https://docs.astral.sh/uv/):
53
-
54
- ```bash
55
- uv add utkit
56
- ```
57
-
58
- ### Optional extras
59
-
60
- | Extra | Included dependencies | Use for |
61
- |---|---|---|
62
- | `api` | `slowapi`, `pydantic` | Rate limiting and API schema for FastAPI |
63
- | `standard` | `psutil`, `jinja2` | Performance monitoring and HTML template rendering |
64
- | `store` | `redis` | Redis cache and key-value store |
65
- | `all` | all of the above | Install every optional dependency at once |
66
-
67
- ```bash
68
- pip install "utkit[api]"
69
- pip install "utkit[standard]"
70
- pip install "utkit[store]"
71
-
72
- # All optional dependencies at once
73
- pip install "utkit[all]"
74
- ```
75
-
76
- ---
77
-
78
- ## Modules
79
-
80
- ### Core
81
-
82
- | Module | Description |
83
- |---|---|
84
- | `auth` | Password hashing and verification |
85
- | `communication.mail` | Send HTML emails via SMTP |
86
- | `privacy.mask` | Mask sensitive data (email, phone, card, string) |
87
- | `privacy.security` | Fernet & RSA encryption, secret key generation, JWT |
88
-
89
- ### Optional
90
-
91
- | Module | Extra | Description |
92
- |---|---|---|
93
- | `api.rate_limit` | `api` | Rate limiting for FastAPI via SlowAPI |
94
- | `api.schema` | `api` | Reusable Pydantic query models (pagination) |
95
- | `utils.performance` | `standard` | Execution time decorator and memory usage |
96
- | `template.render` | `standard` | HTML rendering from Jinja2 files and strings |
97
- | `store.redis` | `store` | Singleton Redis client with JSON serialisation |
98
-
99
- ---
100
-
101
- ## CLI
102
-
103
- ```bash
104
- utkit --version
105
- utkit docs
106
- ```
30
+ # utkit
31
+
32
+ <div style="text-align: center; margin: 1.5rem 0;">
33
+ <img src="https://res.cloudinary.com/daft06bly/image/upload/v1777439163/logo_wussdc.png" alt="utkit" style="height: 100px; width: auto;" />
34
+ </div>
35
+
36
+ **utkit** is a collection of core libraries for Python development, providing ready-to-use utilities for common tasks such as authentication, email, encryption, caching, rate limiting, and more.
37
+
38
+
39
+ - **Author:** TINS P JOSEPH
40
+ - **Requires:** Python `>=3.12`
41
+ - **License:** MIT
42
+ - **PyPI:** [pypi.org/project/utkit](https://pypi.org/project/utkit/)
43
+
44
+ ---
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install utkit
50
+ ```
51
+
52
+ Or with [uv](https://docs.astral.sh/uv/):
53
+
54
+ ```bash
55
+ uv add utkit
56
+ ```
57
+
58
+ ### Optional extras
59
+
60
+ | Extra | Included dependencies | Use for |
61
+ |---|---|---|
62
+ | `api` | `slowapi`, `pydantic` | Rate limiting and API schema for FastAPI |
63
+ | `standard` | `psutil`, `jinja2` | Performance monitoring and HTML template rendering |
64
+ | `store` | `redis` | Redis cache and key-value store |
65
+ | `all` | all of the above | Install every optional dependency at once |
66
+
67
+ ```bash
68
+ pip install "utkit[api]"
69
+ pip install "utkit[standard]"
70
+ pip install "utkit[store]"
71
+
72
+ # All optional dependencies at once
73
+ pip install "utkit[all]"
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Modules
79
+
80
+ ### Core
81
+
82
+ | Module | Description |
83
+ |---|---|
84
+ | `auth` | Password hashing and verification |
85
+ | `communication.mail` | Send HTML emails via SMTP |
86
+ | `privacy.mask` | Mask sensitive data (email, phone, card, string) |
87
+ | `privacy.security` | Fernet & RSA encryption, secret key generation, JWT |
88
+
89
+ ### Optional
90
+
91
+ | Module | Extra | Description |
92
+ |---|---|---|
93
+ | `api.rate_limit` | `api` | Rate limiting for FastAPI via SlowAPI |
94
+ | `api.schema` | `api` | Reusable Pydantic query models (pagination) |
95
+ | `utils.performance` | `standard` | Execution time decorator and memory usage |
96
+ | `template.render` | `standard` | HTML rendering from Jinja2 files and strings |
97
+ | `store.redis` | `store` | Singleton Redis client with JSON serialisation |
98
+
99
+ ---
100
+
101
+ ## CLI
102
+
103
+ ```bash
104
+ utkit --version
105
+ utkit docs
106
+ ```
@@ -1,77 +1,77 @@
1
- # utkit
2
-
3
- <div style="text-align: center; margin: 1.5rem 0;">
4
- <img src="https://res.cloudinary.com/daft06bly/image/upload/v1777439163/logo_wussdc.png" alt="utkit" style="height: 100px; width: auto;" />
5
- </div>
6
-
7
- **utkit** is a collection of core libraries for Python development, providing ready-to-use utilities for common tasks such as authentication, email, encryption, caching, rate limiting, and more.
8
-
9
-
10
- - **Author:** TINS P JOSEPH
11
- - **Requires:** Python `>=3.12`
12
- - **License:** MIT
13
- - **PyPI:** [pypi.org/project/utkit](https://pypi.org/project/utkit/)
14
-
15
- ---
16
-
17
- ## Installation
18
-
19
- ```bash
20
- pip install utkit
21
- ```
22
-
23
- Or with [uv](https://docs.astral.sh/uv/):
24
-
25
- ```bash
26
- uv add utkit
27
- ```
28
-
29
- ### Optional extras
30
-
31
- | Extra | Included dependencies | Use for |
32
- |---|---|---|
33
- | `api` | `slowapi`, `pydantic` | Rate limiting and API schema for FastAPI |
34
- | `standard` | `psutil`, `jinja2` | Performance monitoring and HTML template rendering |
35
- | `store` | `redis` | Redis cache and key-value store |
36
- | `all` | all of the above | Install every optional dependency at once |
37
-
38
- ```bash
39
- pip install "utkit[api]"
40
- pip install "utkit[standard]"
41
- pip install "utkit[store]"
42
-
43
- # All optional dependencies at once
44
- pip install "utkit[all]"
45
- ```
46
-
47
- ---
48
-
49
- ## Modules
50
-
51
- ### Core
52
-
53
- | Module | Description |
54
- |---|---|
55
- | `auth` | Password hashing and verification |
56
- | `communication.mail` | Send HTML emails via SMTP |
57
- | `privacy.mask` | Mask sensitive data (email, phone, card, string) |
58
- | `privacy.security` | Fernet & RSA encryption, secret key generation, JWT |
59
-
60
- ### Optional
61
-
62
- | Module | Extra | Description |
63
- |---|---|---|
64
- | `api.rate_limit` | `api` | Rate limiting for FastAPI via SlowAPI |
65
- | `api.schema` | `api` | Reusable Pydantic query models (pagination) |
66
- | `utils.performance` | `standard` | Execution time decorator and memory usage |
67
- | `template.render` | `standard` | HTML rendering from Jinja2 files and strings |
68
- | `store.redis` | `store` | Singleton Redis client with JSON serialisation |
69
-
70
- ---
71
-
72
- ## CLI
73
-
74
- ```bash
75
- utkit --version
76
- utkit docs
77
- ```
1
+ # utkit
2
+
3
+ <div style="text-align: center; margin: 1.5rem 0;">
4
+ <img src="https://res.cloudinary.com/daft06bly/image/upload/v1777439163/logo_wussdc.png" alt="utkit" style="height: 100px; width: auto;" />
5
+ </div>
6
+
7
+ **utkit** is a collection of core libraries for Python development, providing ready-to-use utilities for common tasks such as authentication, email, encryption, caching, rate limiting, and more.
8
+
9
+
10
+ - **Author:** TINS P JOSEPH
11
+ - **Requires:** Python `>=3.12`
12
+ - **License:** MIT
13
+ - **PyPI:** [pypi.org/project/utkit](https://pypi.org/project/utkit/)
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install utkit
21
+ ```
22
+
23
+ Or with [uv](https://docs.astral.sh/uv/):
24
+
25
+ ```bash
26
+ uv add utkit
27
+ ```
28
+
29
+ ### Optional extras
30
+
31
+ | Extra | Included dependencies | Use for |
32
+ |---|---|---|
33
+ | `api` | `slowapi`, `pydantic` | Rate limiting and API schema for FastAPI |
34
+ | `standard` | `psutil`, `jinja2` | Performance monitoring and HTML template rendering |
35
+ | `store` | `redis` | Redis cache and key-value store |
36
+ | `all` | all of the above | Install every optional dependency at once |
37
+
38
+ ```bash
39
+ pip install "utkit[api]"
40
+ pip install "utkit[standard]"
41
+ pip install "utkit[store]"
42
+
43
+ # All optional dependencies at once
44
+ pip install "utkit[all]"
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Modules
50
+
51
+ ### Core
52
+
53
+ | Module | Description |
54
+ |---|---|
55
+ | `auth` | Password hashing and verification |
56
+ | `communication.mail` | Send HTML emails via SMTP |
57
+ | `privacy.mask` | Mask sensitive data (email, phone, card, string) |
58
+ | `privacy.security` | Fernet & RSA encryption, secret key generation, JWT |
59
+
60
+ ### Optional
61
+
62
+ | Module | Extra | Description |
63
+ |---|---|---|
64
+ | `api.rate_limit` | `api` | Rate limiting for FastAPI via SlowAPI |
65
+ | `api.schema` | `api` | Reusable Pydantic query models (pagination) |
66
+ | `utils.performance` | `standard` | Execution time decorator and memory usage |
67
+ | `template.render` | `standard` | HTML rendering from Jinja2 files and strings |
68
+ | `store.redis` | `store` | Singleton Redis client with JSON serialisation |
69
+
70
+ ---
71
+
72
+ ## CLI
73
+
74
+ ```bash
75
+ utkit --version
76
+ utkit docs
77
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "utkit"
3
- version = "0.6.0"
3
+ version = "0.8.0"
4
4
  description = "core libraries for development"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,6 +1,6 @@
1
- def main() -> None:
2
- print("Hello from utkit!")
3
-
4
-
5
- #TODO - Add more core utilities and libraries here as needed.
1
+ def main() -> None:
2
+ print("Hello from utkit!")
3
+
4
+
5
+ #TODO - Add more core utilities and libraries here as needed.
6
6
  #TODO : redis, logging,passlib, fastapi utils,sqlalchemy utils, etc.
@@ -1,9 +1,9 @@
1
- from __future__ import annotations
2
- from slowapi import Limiter, _rate_limit_exceeded_handler as rate_limit_exceeded_handler
3
- from slowapi.util import get_remote_address
4
-
5
- __all__ = ["initialize_rate_limiter", "rate_limit_exceeded_handler"]
6
-
7
-
8
- def initialize_rate_limiter(rate_limit_default: str = "100/minute") -> Limiter:
9
- return Limiter(key_func=get_remote_address, default_limits=[rate_limit_default])
1
+ from __future__ import annotations
2
+ from slowapi import Limiter, _rate_limit_exceeded_handler as rate_limit_exceeded_handler
3
+ from slowapi.util import get_remote_address
4
+
5
+ __all__ = ["initialize_rate_limiter", "rate_limit_exceeded_handler"]
6
+
7
+
8
+ def initialize_rate_limiter(rate_limit_default: str = "100/minute") -> Limiter:
9
+ return Limiter(key_func=get_remote_address, default_limits=[rate_limit_default])
@@ -1,4 +1,4 @@
1
- from __future__ import annotations
2
- from slowapi.errors import RateLimitExceeded as RateLimitExceededError
3
-
4
- __all__ = ["RateLimitExceededError"]
1
+ from __future__ import annotations
2
+ from slowapi.errors import RateLimitExceeded as RateLimitExceededError
3
+
4
+ __all__ = ["RateLimitExceededError"]
@@ -1,4 +1,4 @@
1
- from __future__ import annotations
2
- from slowapi.middleware import SlowAPIMiddleware as RateLimitMiddleware
3
-
4
- __all__ = ["RateLimitMiddleware"]
1
+ from __future__ import annotations
2
+ from slowapi.middleware import SlowAPIMiddleware as RateLimitMiddleware
3
+
4
+ __all__ = ["RateLimitMiddleware"]
@@ -1,7 +1,7 @@
1
- from pydantic import BaseModel, Field
2
-
3
-
4
- class PaginationParams(BaseModel):
5
- page: int = Field(1, gt=0 ,description="Page number, starting from 1")
6
- page_size: int = Field(10, ge=0, description="Number of items per page")
1
+ from pydantic import BaseModel, Field
2
+
3
+
4
+ class PaginationParams(BaseModel):
5
+ page: int = Field(1, gt=0 ,description="Page number, starting from 1")
6
+ page_size: int = Field(10, ge=0, description="Number of items per page")
7
7
 
@@ -1,16 +1,16 @@
1
- from __future__ import annotations
2
-
3
- from pwdlib import PasswordHash
4
-
5
- password_hash = PasswordHash.recommended()
6
-
7
- __all__ = [
8
- "verify_password","create_password_hash"
9
- ]
10
-
11
- def verify_password(plain_password, hashed_password):
12
- return password_hash.verify(plain_password, hashed_password)
13
-
14
-
15
- def create_password_hash(password):
1
+ from __future__ import annotations
2
+
3
+ from pwdlib import PasswordHash
4
+
5
+ password_hash = PasswordHash.recommended()
6
+
7
+ __all__ = [
8
+ "verify_password","create_password_hash"
9
+ ]
10
+
11
+ def verify_password(plain_password, hashed_password):
12
+ return password_hash.verify(plain_password, hashed_password)
13
+
14
+
15
+ def create_password_hash(password):
16
16
  return password_hash.hash(password)
@@ -1,52 +1,52 @@
1
- import subprocess
2
- from pathlib import Path
3
-
4
- import typer
5
- from importlib.metadata import version as get_version
6
-
7
- app = typer.Typer(no_args_is_help=True, help="utkit - core libraries for development.")
8
-
9
-
10
- def _version_callback(value: bool) -> None:
11
- if value:
12
- typer.echo(f"utkit v{get_version('utkit')}")
13
- raise typer.Exit()
14
-
15
-
16
- @app.callback()
17
- def callback(
18
- version: bool = typer.Option(
19
- None,
20
- "--version",
21
- callback=_version_callback,
22
- is_eager=True,
23
- help="Show version and exit.",
24
- ),
25
- ) -> None:
26
- pass
27
-
28
-
29
- @app.command()
30
- def version() -> None:
31
- """Show the current version of utkit."""
32
- typer.echo(f"utkit v{get_version('utkit')}")
33
-
34
-
35
- @app.command()
36
- def docs() -> None:
37
- """Serve the utkit documentation locally on port 8005 and open in browser."""
38
- docs_dir = Path(__file__).parent.parent / "documentation"
39
- if not docs_dir.exists():
40
- typer.echo(f"Documentation folder not found: {docs_dir}", err=True)
41
- raise typer.Exit(code=1)
42
-
43
- typer.echo("Starting docs server at http://localhost:8005 ...")
44
- subprocess.run(
45
- ["zensical", "serve", "--dev-addr", "localhost:8005", "--open"],
46
- cwd=docs_dir,
47
- check=True,
48
- )
49
-
50
-
51
- def main() -> None:
52
- app()
1
+ import subprocess
2
+ from pathlib import Path
3
+
4
+ import typer
5
+ from importlib.metadata import version as get_version
6
+
7
+ app = typer.Typer(no_args_is_help=True, help="utkit - core libraries for development.")
8
+
9
+
10
+ def _version_callback(value: bool) -> None:
11
+ if value:
12
+ typer.echo(f"utkit v{get_version('utkit')}")
13
+ raise typer.Exit()
14
+
15
+
16
+ @app.callback()
17
+ def callback(
18
+ version: bool = typer.Option(
19
+ None,
20
+ "--version",
21
+ callback=_version_callback,
22
+ is_eager=True,
23
+ help="Show version and exit.",
24
+ ),
25
+ ) -> None:
26
+ pass
27
+
28
+
29
+ @app.command()
30
+ def version() -> None:
31
+ """Show the current version of utkit."""
32
+ typer.echo(f"utkit v{get_version('utkit')}")
33
+
34
+
35
+ @app.command()
36
+ def docs() -> None:
37
+ """Serve the utkit documentation locally on port 8005 and open in browser."""
38
+ docs_dir = Path(__file__).parent.parent / "documentation"
39
+ if not docs_dir.exists():
40
+ typer.echo(f"Documentation folder not found: {docs_dir}", err=True)
41
+ raise typer.Exit(code=1)
42
+
43
+ typer.echo("Starting docs server at http://localhost:8005 ...")
44
+ subprocess.run(
45
+ ["zensical", "serve", "--dev-addr", "localhost:8005", "--open"],
46
+ cwd=docs_dir,
47
+ check=True,
48
+ )
49
+
50
+
51
+ def main() -> None:
52
+ app()
@@ -0,0 +1,82 @@
1
+ from __future__ import annotations
2
+
3
+ import smtplib
4
+ import ssl
5
+ from dataclasses import dataclass, field
6
+ from email.message import EmailMessage
7
+
8
+
9
+ @dataclass
10
+ class SMTPConfig:
11
+ """SMTP connection configuration."""
12
+
13
+ host: str
14
+ port: int
15
+ username: str
16
+ password: str
17
+ use_tls: bool = True
18
+
19
+
20
+ @dataclass
21
+ class MailMessage:
22
+ """Email message parameters."""
23
+
24
+ subject: str
25
+ from_address: str
26
+ to: list[str]
27
+ cc: list[str] = field(default_factory=list)
28
+ bcc: list[str] = field(default_factory=list)
29
+ reply_to: str | None = None
30
+ text: str | None = None
31
+ html: str | None = None
32
+
33
+
34
+ def send_mail(config: SMTPConfig, message: MailMessage) -> None:
35
+ """Send an email via SMTP.
36
+
37
+ Args:
38
+ config: SMTP server connection settings.
39
+ message: Email content and addressing details.
40
+
41
+ Raises:
42
+ ValueError: If both text and html are None, or if port is unsupported.
43
+ """
44
+ if not message.text and not message.html:
45
+ raise ValueError("Either 'text' or 'html' content must be provided")
46
+
47
+ msg = EmailMessage()
48
+ msg["Subject"] = message.subject
49
+ msg["From"] = message.from_address
50
+ msg["To"] = ", ".join(message.to)
51
+
52
+ if message.cc:
53
+ msg["Cc"] = ", ".join(message.cc)
54
+ if message.reply_to:
55
+ msg["Reply-To"] = message.reply_to
56
+
57
+ # Set content based on what's provided
58
+ if message.text and message.html:
59
+ # Both text and html: set text first, then add html as alternative
60
+ msg.set_content(message.text)
61
+ msg.add_alternative(message.html, subtype="html")
62
+ elif message.text:
63
+ # Only text
64
+ msg.set_content(message.text)
65
+ else:
66
+ # Only html
67
+ msg.set_content(message.html, subtype="html")
68
+
69
+ if config.port == 465:
70
+ # Use SMTP_SSL for port 465
71
+ context = ssl.create_default_context()
72
+ with smtplib.SMTP_SSL(config.host, config.port, context=context) as server:
73
+ server.login(config.username, config.password)
74
+ server.send_message(msg)
75
+ elif config.port == 587:
76
+ # Use SMTP with STARTTLS for port 587
77
+ with smtplib.SMTP(config.host, config.port) as server:
78
+ server.starttls()
79
+ server.login(config.username, config.password)
80
+ server.send_message(msg)
81
+ else:
82
+ raise ValueError(f"Unsupported SMTP port: {config.port}. Use 465 or 587.")