async-task-kit 0.1.1__tar.gz → 0.1.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.
Files changed (23) hide show
  1. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/PKG-INFO +2 -1
  2. async_task_kit-0.1.2/async_task_kit/utils/env_loader.py +55 -0
  3. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit.egg-info/PKG-INFO +2 -1
  4. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit.egg-info/requires.txt +1 -0
  5. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/pyproject.toml +7 -3
  6. async_task_kit-0.1.1/async_task_kit/utils/env_loader.py +0 -16
  7. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/LICENSE +0 -0
  8. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/README.md +0 -0
  9. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/__init__.py +0 -0
  10. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/consumer/__init__.py +0 -0
  11. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/consumer/base.py +0 -0
  12. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/consumer/coroutine.py +0 -0
  13. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/consumer/process.py +0 -0
  14. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/consumer/thread.py +0 -0
  15. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/core/__init__.py +0 -0
  16. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/core/processor.py +0 -0
  17. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/core/rabbitmq.py +0 -0
  18. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/utils/__init__.py +0 -0
  19. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit/utils/logger.py +0 -0
  20. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit.egg-info/SOURCES.txt +0 -0
  21. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit.egg-info/dependency_links.txt +0 -0
  22. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/async_task_kit.egg-info/top_level.txt +0 -0
  23. {async_task_kit-0.1.1 → async_task_kit-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: async-task-kit
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A powerful async task processing kit based on RabbitMQ with Coroutine, Thread, and Process support.
5
5
  Author-email: realwrtoff <realwrtoff@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -10,6 +10,7 @@ Requires-Python: >=3.12
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: aio-pika>=9.4.0
13
+ Requires-Dist: asyncpg>=0.31.0
13
14
  Requires-Dist: python-dotenv>=1.0.0
14
15
  Dynamic: license-file
15
16
 
@@ -0,0 +1,55 @@
1
+ from __future__ import annotations
2
+ import os
3
+ from dotenv import load_dotenv
4
+
5
+ load_dotenv()
6
+
7
+
8
+ class EnvLoader:
9
+ def __init__(self, task_id: str | None = None):
10
+ self.prefix = f"{task_id.upper()}_" if task_id else ""
11
+
12
+ def _candidate_keys(self, key: str) -> list[str]:
13
+ uk = key.upper()
14
+ if self.prefix:
15
+ # 有任务前缀:优先前缀变量,其次全局公共变量
16
+ return [self.prefix + uk, uk]
17
+ # 无task_id,只查全局公共变量
18
+ return [uk]
19
+
20
+ def get(self, key: str, default: str | None = None) -> str | None:
21
+ for k in self._candidate_keys(key):
22
+ val = os.getenv(k)
23
+ if val is not None:
24
+ return val.strip()
25
+ return default
26
+
27
+ def get_int(self, key: str, default: int | None = None) -> int | None:
28
+ raw_val = None
29
+ for k in self._candidate_keys(key):
30
+ raw_val = os.getenv(k)
31
+ if raw_val is not None:
32
+ break
33
+ if raw_val is None:
34
+ return default
35
+ try:
36
+ return int(raw_val.strip())
37
+ except (ValueError, TypeError):
38
+ return default
39
+
40
+ def get_bool(self, key: str, default: bool = False) -> bool:
41
+ raw_val = None
42
+ for k in self._candidate_keys(key):
43
+ raw_val = os.getenv(k)
44
+ if raw_val is not None:
45
+ break
46
+ if raw_val is None:
47
+ return default
48
+ v = raw_val.strip().lower()
49
+ true_set = {"1", "true", "yes", "on", "y"}
50
+ false_set = {"0", "false", "no", "off", "n"}
51
+ if v in true_set:
52
+ return True
53
+ if v in false_set:
54
+ return False
55
+ return default
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: async-task-kit
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A powerful async task processing kit based on RabbitMQ with Coroutine, Thread, and Process support.
5
5
  Author-email: realwrtoff <realwrtoff@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -10,6 +10,7 @@ Requires-Python: >=3.12
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: aio-pika>=9.4.0
13
+ Requires-Dist: asyncpg>=0.31.0
13
14
  Requires-Dist: python-dotenv>=1.0.0
14
15
  Dynamic: license-file
15
16
 
@@ -1,2 +1,3 @@
1
1
  aio-pika>=9.4.0
2
+ asyncpg>=0.31.0
2
3
  python-dotenv>=1.0.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "async-task-kit"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "A powerful async task processing kit based on RabbitMQ with Coroutine, Thread, and Process support."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -13,7 +13,8 @@ authors = [
13
13
  ]
14
14
  dependencies = [
15
15
  "aio-pika>=9.4.0",
16
- "python-dotenv>=1.0.0"
16
+ "asyncpg>=0.31.0",
17
+ "python-dotenv>=1.0.0",
17
18
  ]
18
19
  classifiers = [
19
20
  "Programming Language :: Python :: 3",
@@ -21,6 +22,9 @@ classifiers = [
21
22
  "Operating System :: OS Independent",
22
23
  ]
23
24
 
25
+ [dependency-groups]
26
+ dev = ["build", "twine"]
27
+
24
28
  [tool.setuptools.packages.find]
25
29
  where = ["."]
26
- include = ["async_task_kit*"]
30
+ include = ["async_task_kit*"]
@@ -1,16 +0,0 @@
1
- import os
2
- from dotenv import load_dotenv
3
- load_dotenv()
4
-
5
- class EnvLoader:
6
- def __init__(self, task_id=None):
7
- self.prefix = f"{task_id}_".upper() if task_id else ""
8
-
9
- def get(self, key, default=None):
10
- return os.getenv(f"{self.prefix}{key}", default)
11
-
12
- def get_int(self, key, default=1):
13
- try:
14
- return int(os.getenv(f"{self.prefix}{key}", default))
15
- except:
16
- return default
File without changes
File without changes
File without changes