asyncfast-cli 0.22.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.
- asyncfast_cli-0.22.0/PKG-INFO +17 -0
- asyncfast_cli-0.22.0/README.md +0 -0
- asyncfast_cli-0.22.0/pyproject.toml +28 -0
- asyncfast_cli-0.22.0/src/asyncfast_cli/__init__.py +0 -0
- asyncfast_cli-0.22.0/src/asyncfast_cli/__main__.py +3 -0
- asyncfast_cli-0.22.0/src/asyncfast_cli/cli.py +79 -0
- asyncfast_cli-0.22.0/src/asyncfast_cli/py.typed +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: asyncfast-cli
|
|
3
|
+
Version: 0.22.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: jack.burridge
|
|
6
|
+
Author-email: jack.burridge <jack.burridge@mail.com>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: amgi-types==0.22.0
|
|
14
|
+
Requires-Dist: typer>=0.16.0
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "uv_build"
|
|
3
|
+
requires = [ "uv-build>=0.8.14,<0.9.0" ]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "asyncfast-cli"
|
|
7
|
+
version = "0.22.0"
|
|
8
|
+
description = "Add your description here"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "jack.burridge", email = "jack.burridge@mail.com" },
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"amgi-types==0.22.0",
|
|
24
|
+
"typer>=0.16.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.uv.sources]
|
|
28
|
+
amgi-types = { workspace = true }
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from importlib.metadata import entry_points
|
|
6
|
+
from typing import Annotated
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
from amgi_types import AMGIApplication
|
|
11
|
+
from typer.main import get_command
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def import_from_string(import_str: Any) -> Any:
|
|
15
|
+
if not isinstance(import_str, str):
|
|
16
|
+
return import_str
|
|
17
|
+
|
|
18
|
+
module_str, _, attrs_str = import_str.partition(":")
|
|
19
|
+
if not module_str or not attrs_str:
|
|
20
|
+
message = (
|
|
21
|
+
'Import string "{import_str}" must be in format "<module>:<attribute>".'
|
|
22
|
+
)
|
|
23
|
+
raise Exception(message.format(import_str=import_str))
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
module = importlib.import_module(module_str)
|
|
27
|
+
except ModuleNotFoundError as exc:
|
|
28
|
+
if exc.name != module_str:
|
|
29
|
+
raise exc from None
|
|
30
|
+
message = 'Could not import module "{module_str}".'
|
|
31
|
+
raise Exception(message.format(module_str=module_str))
|
|
32
|
+
|
|
33
|
+
instance = module
|
|
34
|
+
try:
|
|
35
|
+
for attr_str in attrs_str.split("."):
|
|
36
|
+
instance = getattr(instance, attr_str)
|
|
37
|
+
except AttributeError:
|
|
38
|
+
message = 'Attribute "{attrs_str}" not found in module "{module_str}".'
|
|
39
|
+
raise Exception(message.format(attrs_str=attrs_str, module_str=module_str))
|
|
40
|
+
|
|
41
|
+
return instance
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
app = typer.Typer()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@app.command()
|
|
48
|
+
def asyncapi(app: str) -> None:
|
|
49
|
+
loaded_app = import_from_string(app)
|
|
50
|
+
print(json.dumps(loaded_app.asyncapi(), indent=2))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@app.callback()
|
|
54
|
+
def callback() -> None:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main() -> None:
|
|
59
|
+
sys.path.insert(0, os.getcwd())
|
|
60
|
+
|
|
61
|
+
run_app = typer.Typer()
|
|
62
|
+
app.add_typer(run_app, name="run")
|
|
63
|
+
|
|
64
|
+
for entry_point in entry_points().get("amgi_server", ()):
|
|
65
|
+
try:
|
|
66
|
+
test_app = typer.Typer()
|
|
67
|
+
function = entry_point.load()
|
|
68
|
+
|
|
69
|
+
for name, annotation in function.__annotations__.items():
|
|
70
|
+
if annotation is AMGIApplication:
|
|
71
|
+
function.__annotations__[name] = Annotated[
|
|
72
|
+
AMGIApplication, typer.Argument(parser=import_from_string)
|
|
73
|
+
]
|
|
74
|
+
test_app.command(entry_point.name)(function)
|
|
75
|
+
get_command(test_app)
|
|
76
|
+
run_app.command(entry_point.name)(function)
|
|
77
|
+
except RuntimeError:
|
|
78
|
+
pass
|
|
79
|
+
app()
|
|
File without changes
|