-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: import plugin using import_module (#266)
* feat: import plugin using import_module Signed-off-by: Keming <kemingy94@gmail.com> * exit if err Signed-off-by: Keming <kemingy94@gmail.com> * fix test Signed-off-by: Keming <kemingy94@gmail.com> Signed-off-by: Keming <kemingy94@gmail.com> (cherry picked from commit ebcb3d6)
- Loading branch information
Showing
11 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
from collections import namedtuple | ||
|
||
from .base import BasePlugin | ||
from .falcon_plugin import FalconAsgiPlugin, FalconPlugin | ||
from .flask_plugin import FlaskPlugin | ||
from .starlette_plugin import StarlettePlugin | ||
|
||
__all__ = ["BasePlugin"] | ||
|
||
Plugin = namedtuple("Plugin", ("name", "package", "class_name")) | ||
|
||
PLUGINS = { | ||
"base": BasePlugin, | ||
"flask": FlaskPlugin, | ||
"falcon": FalconPlugin, | ||
"falcon-asgi": FalconAsgiPlugin, | ||
"starlette": StarlettePlugin, | ||
"base": Plugin(".base", __name__, "BasePlugin"), | ||
"flask": Plugin(".flask_plugin", __name__, "FlaskPlugin"), | ||
"falcon": Plugin(".falcon_plugin", __name__, "FalconPlugin"), | ||
"falcon-asgi": Plugin(".falcon_plugin", __name__, "FalconAsgiPlugin"), | ||
"starlette": Plugin(".starlette_plugin", __name__, "StarlettePlugin"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from spectree import SpecTree | ||
|
||
SpecTree("falcon") | ||
SpecTree("falcon-asgi") | ||
print("=> passed falcon plugin import test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from spectree import SpecTree | ||
|
||
SpecTree("flask") | ||
print("=> passed flask plugin import test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from spectree import SpecTree | ||
|
||
SpecTree("starlette") | ||
print("=> passed starlette plugin import test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters