Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
c1e65bf0dc | |||
688381b106 | |||
c3e3367264 | |||
c3d51e29fc | |||
cae2e6d92e | |||
347418bdc5 | |||
153fc8922e | |||
cdbfaeb013 | |||
4062a6ebe4 | |||
46ef6b3938 | |||
c1b9c0fb4a | |||
8ede2998fe | |||
41f974fe6e | |||
e7af5ce322 | |||
7881294554 | |||
b3fd122fcd | |||
1dd48899d7 | |||
f357e97ce5 | |||
2d8ecd424a | |||
affbbc822d | |||
43ea732c5f | |||
708918464f | |||
ed2377c288 | |||
b819eb439c | |||
b3ed7101fc | |||
a3504af376 | |||
81c2f1cba9 | |||
bea5b22251 | |||
e04d0beb68 | |||
08ba097aaa | |||
ea968d94e4 | |||
8e12c72b07 |
@ -6,7 +6,6 @@
|
|||||||
"cpl-core": "src/cpl_core/cpl-core.json",
|
"cpl-core": "src/cpl_core/cpl-core.json",
|
||||||
"cpl-discord": "src/cpl_discord/cpl-discord.json",
|
"cpl-discord": "src/cpl_discord/cpl-discord.json",
|
||||||
"cpl-query": "src/cpl_query/cpl-query.json",
|
"cpl-query": "src/cpl_query/cpl-query.json",
|
||||||
"cpl-reactive-extensions": "src/cpl_reactive_extensions/cpl-reactive-extensions.json",
|
|
||||||
"cpl-translation": "src/cpl_translation/cpl-translation.json",
|
"cpl-translation": "src/cpl_translation/cpl-translation.json",
|
||||||
"set-version": "tools/set_version/set-version.json",
|
"set-version": "tools/set_version/set-version.json",
|
||||||
"set-pip-urls": "tools/set_pip_urls/set-pip-urls.json",
|
"set-pip-urls": "tools/set_pip_urls/set-pip-urls.json",
|
||||||
@ -15,8 +14,7 @@
|
|||||||
"unittests_core": "unittests/unittests_core/unittests_core.json",
|
"unittests_core": "unittests/unittests_core/unittests_core.json",
|
||||||
"unittests_query": "unittests/unittests_query/unittests_query.json",
|
"unittests_query": "unittests/unittests_query/unittests_query.json",
|
||||||
"unittests_shared": "unittests/unittests_shared/unittests_shared.json",
|
"unittests_shared": "unittests/unittests_shared/unittests_shared.json",
|
||||||
"unittests_translation": "unittests/unittests_translation/unittests_translation.json",
|
"unittests_translation": "unittests/unittests_translation/unittests_translation.json"
|
||||||
"unittests_reactive_extenstions": "unittests/unittests_reactive_extenstions/unittests_reactive_extenstions.json"
|
|
||||||
},
|
},
|
||||||
"Scripts": {
|
"Scripts": {
|
||||||
"hello-world": "echo 'Hello World'",
|
"hello-world": "echo 'Hello World'",
|
||||||
@ -42,13 +40,12 @@
|
|||||||
"test": "cpl run unittests",
|
"test": "cpl run unittests",
|
||||||
|
|
||||||
"pre-build-all": "cpl sv $ARGS; cpl spu $ARGS;",
|
"pre-build-all": "cpl sv $ARGS; cpl spu $ARGS;",
|
||||||
"build-all": "cpl build-cli; cpl build-core; cpl build-discord; cpl build-query; cpl build-reactive-extensions; cpl build-translation; cpl build-set-pip-urls; cpl build-set-version",
|
"build-all": "cpl build-cli; cpl build-core; cpl build-discord; cpl build-query; cpl build-translation; cpl build-set-pip-urls; cpl build-set-version",
|
||||||
"ba": "cpl build-all $ARGS",
|
"ba": "cpl build-all $ARGS",
|
||||||
"build-cli": "echo 'Build cpl-cli'; cd ./src/cpl_cli; cpl build; cd ../../;",
|
"build-cli": "echo 'Build cpl-cli'; cd ./src/cpl_cli; cpl build; cd ../../;",
|
||||||
"build-core": "echo 'Build cpl-core'; cd ./src/cpl_core; cpl build; cd ../../;",
|
"build-core": "echo 'Build cpl-core'; cd ./src/cpl_core; cpl build; cd ../../;",
|
||||||
"build-discord": "echo 'Build cpl-discord'; cd ./src/cpl_discord; cpl build; cd ../../;",
|
"build-discord": "echo 'Build cpl-discord'; cd ./src/cpl_discord; cpl build; cd ../../;",
|
||||||
"build-query": "echo 'Build cpl-query'; cd ./src/cpl_query; cpl build; cd ../../;",
|
"build-query": "echo 'Build cpl-query'; cd ./src/cpl_query; cpl build; cd ../../;",
|
||||||
"build-reactive-extensions": "echo 'Build cpl-reactive-x'; cd ./src/cpl_reactive_extensions; cpl build; cd ../../;",
|
|
||||||
"build-translation": "echo 'Build cpl-translation'; cd ./src/cpl_translation; cpl build; cd ../../;",
|
"build-translation": "echo 'Build cpl-translation'; cd ./src/cpl_translation; cpl build; cd ../../;",
|
||||||
"build-set-pip-urls": "echo 'Build set-pip-urls'; cd ./tools/set_pip_urls; cpl build; cd ../../;",
|
"build-set-pip-urls": "echo 'Build set-pip-urls'; cd ./tools/set_pip_urls; cpl build; cd ../../;",
|
||||||
"build-set-version": "echo 'Build set-version'; cd ./tools/set_version; cpl build; cd ../../;",
|
"build-set-version": "echo 'Build set-version'; cd ./tools/set_version; cpl build; cd ../../;",
|
||||||
@ -60,7 +57,6 @@
|
|||||||
"publish-core": "echo 'Publish cpl-core'; cd ./src/cpl_core; cpl publish; cd ../../;",
|
"publish-core": "echo 'Publish cpl-core'; cd ./src/cpl_core; cpl publish; cd ../../;",
|
||||||
"publish-discord": "echo 'Publish cpl-discord'; cd ./src/cpl_discord; cpl publish; cd ../../;",
|
"publish-discord": "echo 'Publish cpl-discord'; cd ./src/cpl_discord; cpl publish; cd ../../;",
|
||||||
"publish-query": "echo 'Publish cpl-query'; cd ./src/cpl_query; cpl publish; cd ../../;",
|
"publish-query": "echo 'Publish cpl-query'; cd ./src/cpl_query; cpl publish; cd ../../;",
|
||||||
"publish-reactive-extensions": "echo 'Publish cpl-reactive-x'; cd ./src/cpl_reactive_extensions; cpl publish; cd ../../;",
|
|
||||||
"publish-translation": "echo 'Publish cpl-translation'; cd ./src/cpl_translation; cpl publish; cd ../../;",
|
"publish-translation": "echo 'Publish cpl-translation'; cd ./src/cpl_translation; cpl publish; cd ../../;",
|
||||||
|
|
||||||
"upload-prod-cli": "echo 'PROD Upload cpl-cli'; cpl upl-prod-cli;",
|
"upload-prod-cli": "echo 'PROD Upload cpl-cli'; cpl upl-prod-cli;",
|
||||||
@ -75,9 +71,6 @@
|
|||||||
"upload-prod-query": "echo 'PROD Upload cpl-query'; cpl upl-prod-query;",
|
"upload-prod-query": "echo 'PROD Upload cpl-query'; cpl upl-prod-query;",
|
||||||
"upl-prod-query": "twine upload -r pip.sh-edraft.de dist/cpl-query/publish/setup/*",
|
"upl-prod-query": "twine upload -r pip.sh-edraft.de dist/cpl-query/publish/setup/*",
|
||||||
|
|
||||||
"upload-prod-reactive-extensions": "echo 'PROD Upload cpl-reactive-extensions'; cpl upl-prod-query;",
|
|
||||||
"upl-prod-reactive-extensions": "twine upload -r pip.sh-edraft.de dist/cpl-reactive-extensions/publish/setup/*",
|
|
||||||
|
|
||||||
"upload-prod-translation": "echo 'PROD Upload cpl-translation'; cpl upl-prod-translation;",
|
"upload-prod-translation": "echo 'PROD Upload cpl-translation'; cpl upl-prod-translation;",
|
||||||
"upl-prod-translation": "twine upload -r pip.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
"upl-prod-translation": "twine upload -r pip.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
||||||
|
|
||||||
@ -93,9 +86,6 @@
|
|||||||
"upload-exp-query": "echo 'EXP Upload cpl-query'; cpl upl-exp-query;",
|
"upload-exp-query": "echo 'EXP Upload cpl-query'; cpl upl-exp-query;",
|
||||||
"upl-exp-query": "twine upload -r pip-exp.sh-edraft.de dist/cpl-query/publish/setup/*",
|
"upl-exp-query": "twine upload -r pip-exp.sh-edraft.de dist/cpl-query/publish/setup/*",
|
||||||
|
|
||||||
"upload-exp-reactive-extensions": "echo 'EXP Upload cpl-reactive-extensions'; cpl upl-exp-query;",
|
|
||||||
"upl-exp-reactive-extensions": "twine upload -r pip-exp.sh-edraft.de dist/cpl-reactive-extensions/publish/setup/*",
|
|
||||||
|
|
||||||
"upload-exp-translation": "echo 'EXP Upload cpl-translation'; cpl upl-exp-translation;",
|
"upload-exp-translation": "echo 'EXP Upload cpl-translation'; cpl upl-exp-translation;",
|
||||||
"upl-exp-translation": "twine upload -r pip-exp.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
"upl-exp-translation": "twine upload -r pip-exp.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
||||||
|
|
||||||
@ -111,9 +101,6 @@
|
|||||||
"upload-dev-query": "echo 'DEV Upload cpl-query'; cpl upl-dev-query;",
|
"upload-dev-query": "echo 'DEV Upload cpl-query'; cpl upl-dev-query;",
|
||||||
"upl-dev-query": "twine upload -r pip-dev.sh-edraft.de dist/cpl-query/publish/setup/*",
|
"upl-dev-query": "twine upload -r pip-dev.sh-edraft.de dist/cpl-query/publish/setup/*",
|
||||||
|
|
||||||
"upload-dev-reactive-extensions": "echo 'DEV Upload cpl-reactive-extensions'; cpl upl-dev-query;",
|
|
||||||
"upl-dev-reactive-extensions": "twine upload -r pip-dev.sh-edraft.de dist/cpl-reactive-extensions/publish/setup/*",
|
|
||||||
|
|
||||||
"upload-dev-translation": "echo 'DEV Upload cpl-translation'; cpl upl-dev-translation;",
|
"upload-dev-translation": "echo 'DEV Upload cpl-translation'; cpl upl-dev-translation;",
|
||||||
"upl-dev-translation": "twine upload -r pip-dev.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
"upl-dev-translation": "twine upload -r pip-dev.sh-edraft.de dist/cpl-translation/publish/setup/*",
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli"
|
__title__ = "cpl_cli"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli"
|
__title__ = "cpl_cli"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .main import main
|
|||||||
from .startup import Startup
|
from .startup import Startup
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli._templates"
|
__title__ = "cpl_cli._templates"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli._templates.build"
|
__title__ = "cpl_cli._templates.build"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -19,19 +19,19 @@ class InitTemplate:
|
|||||||
|
|
||||||
\"\"\"
|
\"\"\"
|
||||||
|
|
||||||
__title__ = '$Title'
|
__title__ = "$Title"
|
||||||
__author__ = '$Author'
|
__author__ = "$Author"
|
||||||
__license__ = '$LicenseName'
|
__license__ = "$LicenseName"
|
||||||
__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'
|
__copyright__ = "Copyright (c) $CopyrightDate $CopyrightName"
|
||||||
__version__ = '$Version'
|
__version__ = "$Version"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
$Imports
|
$Imports
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major='$Major', minor='$Minor', micro='$Micro')
|
version_info = VersionInfo(major="$Major", minor="$Minor", micro="$Micro")
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli._templates.publish"
|
__title__ = "cpl_cli._templates.publish"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.abc"
|
__title__ = "cpl_cli.abc"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.command"
|
__title__ = "cpl_cli.command"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -29,4 +29,4 @@ from .publish_service import PublishService
|
|||||||
from .version_service import VersionService
|
from .version_service import VersionService
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -154,6 +154,24 @@ class UpdateService(CommandABC):
|
|||||||
Console.write_line(f"\tUpdate with {Pip.get_executable()} -m pip install --upgrade <package>")
|
Console.write_line(f"\tUpdate with {Pip.get_executable()} -m pip install --upgrade <package>")
|
||||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||||
|
|
||||||
|
def _save_formatted_package_name_to_deps_collection(self, deps: [str], old_package: str, new_package: str):
|
||||||
|
if old_package not in deps:
|
||||||
|
return
|
||||||
|
|
||||||
|
initial_package = new_package
|
||||||
|
|
||||||
|
if "/" in new_package:
|
||||||
|
new_package = new_package.split("/")[0]
|
||||||
|
|
||||||
|
if "\r" in new_package:
|
||||||
|
new_package = new_package.replace("\r", "")
|
||||||
|
|
||||||
|
if new_package == old_package:
|
||||||
|
return
|
||||||
|
|
||||||
|
index = deps.index(old_package)
|
||||||
|
deps[index] = new_package
|
||||||
|
|
||||||
def _project_json_update_dependency(self, old_package: str, new_package: str):
|
def _project_json_update_dependency(self, old_package: str, new_package: str):
|
||||||
"""
|
"""
|
||||||
Writes new package version to project.json
|
Writes new package version to project.json
|
||||||
@ -164,15 +182,12 @@ class UpdateService(CommandABC):
|
|||||||
if self._is_simulation:
|
if self._is_simulation:
|
||||||
return
|
return
|
||||||
|
|
||||||
if old_package in self._project_settings.dependencies:
|
self._save_formatted_package_name_to_deps_collection(
|
||||||
index = self._project_settings.dependencies.index(old_package)
|
self._project_settings.dependencies, old_package, new_package
|
||||||
if "/" in new_package:
|
)
|
||||||
new_package = new_package.split("/")[0]
|
self._save_formatted_package_name_to_deps_collection(
|
||||||
|
self._project_settings.dev_dependencies, old_package, new_package
|
||||||
if "\r" in new_package:
|
)
|
||||||
new_package = new_package.replace("\r", "")
|
|
||||||
|
|
||||||
self._project_settings.dependencies[index] = new_package
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
ProjectSettings.__name__: SettingsHelper.get_project_settings_dict(self._project_settings),
|
ProjectSettings.__name__: SettingsHelper.get_project_settings_dict(self._project_settings),
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.configuration"
|
__title__ = "cpl_cli.configuration"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ from .workspace_settings import WorkspaceSettings
|
|||||||
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
|
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "cpl-cli",
|
"Name": "cpl-cli",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2023",
|
"Major": "2024",
|
||||||
"Minor": "4",
|
"Minor": "7",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
@ -11,15 +11,15 @@
|
|||||||
"Description": "CPL CLI",
|
"Description": "CPL CLI",
|
||||||
"LongDescription": "CPL Command Line Interface",
|
"LongDescription": "CPL Command Line Interface",
|
||||||
"URL": "https://www.sh-edraft.de",
|
"URL": "https://www.sh-edraft.de",
|
||||||
"CopyrightDate": "2020 - 2023",
|
"CopyrightDate": "2020 - 2024",
|
||||||
"CopyrightName": "sh-edraft.de",
|
"CopyrightName": "sh-edraft.de",
|
||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core>=2023.4.0"
|
"cpl-core>=2024.6.2024.07.0"
|
||||||
],
|
],
|
||||||
"DevDependencies": [],
|
"DevDependencies": [],
|
||||||
"PythonVersion": ">=3.10",
|
"PythonVersion": ">=3.12",
|
||||||
"PythonPath": {
|
"PythonPath": {
|
||||||
"linux": "../../venv"
|
"linux": "../../venv"
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.helper"
|
__title__ = "cpl_cli.helper"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.live_server"
|
__title__ = "cpl_cli.live_server"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
import importlib.metadata
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
from cpl_cli.cli import CLI
|
from cpl_cli.cli import CLI
|
||||||
from cpl_cli.startup import Startup
|
from cpl_cli.startup import Startup
|
||||||
from cpl_cli.startup_argument_extension import StartupArgumentExtension
|
from cpl_cli.startup_argument_extension import StartupArgumentExtension
|
||||||
@ -16,13 +15,12 @@ def get_startup_extensions() -> list[Type[StartupExtensionABC]]:
|
|||||||
blacklisted_packages = ["cpl-cli"]
|
blacklisted_packages = ["cpl-cli"]
|
||||||
startup_extensions = []
|
startup_extensions = []
|
||||||
|
|
||||||
installed_packages = pkg_resources.working_set
|
installed_packages = importlib.metadata.distributions()
|
||||||
for p in installed_packages:
|
for p in installed_packages:
|
||||||
package = str(p).split(" ")[0]
|
if not p.name.startswith("cpl-") or p.name in blacklisted_packages:
|
||||||
if not package.startswith("cpl-") or package in blacklisted_packages:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
package = package.replace("-", "_")
|
package = p.name.replace("-", "_")
|
||||||
loaded_package = __import__(package)
|
loaded_package = __import__(package)
|
||||||
if "__cli_startup_extension__" not in dir(loaded_package):
|
if "__cli_startup_extension__" not in dir(loaded_package):
|
||||||
continue
|
continue
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.migrations"
|
__title__ = "cpl_cli.migrations"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.migrations.base"
|
__title__ = "cpl_cli.migrations.base"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.migrations.service"
|
__title__ = "cpl_cli.migrations.service"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.publish"
|
__title__ = "cpl_cli.publish"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .publisher_abc import PublisherABC
|
|||||||
from .publisher_service import PublisherService
|
from .publisher_service import PublisherService
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.source_creator"
|
__title__ = "cpl_cli.source_creator"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -28,10 +28,13 @@ class StartupArgumentExtension(StartupExtensionABC):
|
|||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "add", ["a", "A"], AddService, True, validators=[WorkspaceValidator]
|
ArgumentTypeEnum.Executable, "", "add", ["a", "A"], AddService, True, validators=[WorkspaceValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"])
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"])
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "build", ["b", "B"], BuildService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "build", ["b", "B"], BuildService, True, validators=[ProjectValidator]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(ArgumentTypeEnum.Executable, "", "generate", ["g", "G"], GenerateService, True)
|
config.create_console_argument(ArgumentTypeEnum.Executable, "", "generate", ["g", "G"], GenerateService, True)
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "install", ["i", "I"], InstallService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "install", ["i", "I"], InstallService, True, validators=[ProjectValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"]).add_console_argument(
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"]).add_console_argument(
|
||||||
@ -45,6 +48,7 @@ class StartupArgumentExtension(StartupExtensionABC):
|
|||||||
).add_console_argument(
|
).add_console_argument(
|
||||||
ArgumentTypeEnum.Flag, "--", "cpl-dev", ["cd", "CD"]
|
ArgumentTypeEnum.Flag, "--", "cpl-dev", ["cd", "CD"]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "new", ["n", "N"], NewService, True
|
ArgumentTypeEnum.Executable, "", "new", ["n", "N"], NewService, True
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "async", ["a", "A"]).add_console_argument(
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "async", ["a", "A"]).add_console_argument(
|
||||||
@ -60,18 +64,23 @@ class StartupArgumentExtension(StartupExtensionABC):
|
|||||||
).add_console_argument(
|
).add_console_argument(
|
||||||
ArgumentTypeEnum.Flag, "--", "base", ["b", "B"]
|
ArgumentTypeEnum.Flag, "--", "base", ["b", "B"]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "publish", ["p", "P"], PublishService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "publish", ["p", "P"], PublishService, True, validators=[ProjectValidator]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "remove", ["r", "R"], RemoveService, True, validators=[WorkspaceValidator]
|
ArgumentTypeEnum.Executable, "", "remove", ["r", "R"], RemoveService, True, validators=[WorkspaceValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"])
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"])
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "run", [], RunService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "run", [], RunService, True, validators=[ProjectValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"])
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"])
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "start", ["s", "S"], StartService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "start", ["s", "S"], StartService, True, validators=[ProjectValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"])
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "dev", ["d", "D"])
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable,
|
ArgumentTypeEnum.Executable,
|
||||||
"",
|
"",
|
||||||
@ -85,6 +94,7 @@ class StartupArgumentExtension(StartupExtensionABC):
|
|||||||
).add_console_argument(
|
).add_console_argument(
|
||||||
ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"]
|
ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(
|
config.create_console_argument(
|
||||||
ArgumentTypeEnum.Executable, "", "update", ["u", "U"], UpdateService, True, validators=[ProjectValidator]
|
ArgumentTypeEnum.Executable, "", "update", ["u", "U"], UpdateService, True, validators=[ProjectValidator]
|
||||||
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"]).add_console_argument(
|
).add_console_argument(ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"]).add_console_argument(
|
||||||
@ -94,6 +104,7 @@ class StartupArgumentExtension(StartupExtensionABC):
|
|||||||
).add_console_argument(
|
).add_console_argument(
|
||||||
ArgumentTypeEnum.Flag, "--", "cpl-dev", ["cd", "CD"]
|
ArgumentTypeEnum.Flag, "--", "cpl-dev", ["cd", "CD"]
|
||||||
)
|
)
|
||||||
|
|
||||||
config.create_console_argument(ArgumentTypeEnum.Executable, "", "version", ["v", "V"], VersionService, True)
|
config.create_console_argument(ArgumentTypeEnum.Executable, "", "version", ["v", "V"], VersionService, True)
|
||||||
|
|
||||||
config.for_each_argument(lambda a: a.add_console_argument(ArgumentTypeEnum.Flag, "--", "help", ["h", "H"]))
|
config.for_each_argument(lambda a: a.add_console_argument(ArgumentTypeEnum.Flag, "--", "help", ["h", "H"]))
|
||||||
|
@ -6,7 +6,7 @@ cpl-cli CPL CLI
|
|||||||
|
|
||||||
CPL Command Line Interface
|
CPL Command Line Interface
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL Command Line Interface
|
|||||||
__title__ = "cpl_cli.validators"
|
__title__ = "cpl_cli.validators"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2024.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2024", minor="10", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core"
|
__title__ = "cpl_core"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.application"
|
__title__ = "cpl_core.application"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -29,4 +29,4 @@ from .startup_abc import StartupABC
|
|||||||
from .startup_extension_abc import StartupExtensionABC
|
from .startup_extension_abc import StartupExtensionABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.configuration"
|
__title__ = "cpl_core.configuration"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -35,4 +35,4 @@ from .validator_abc import ValidatorABC
|
|||||||
from .variable_argument import VariableArgument
|
from .variable_argument import VariableArgument
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -24,7 +24,7 @@ from cpl_core.dependency_injection.service_provider_abc import ServiceProviderAB
|
|||||||
from cpl_core.environment.application_environment import ApplicationEnvironment
|
from cpl_core.environment.application_environment import ApplicationEnvironment
|
||||||
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||||
from cpl_core.environment.environment_name_enum import EnvironmentNameEnum
|
from cpl_core.environment.environment_name_enum import EnvironmentNameEnum
|
||||||
from cpl_core.type import T
|
from cpl_core.type import T, R
|
||||||
from cpl_core.utils.json_processor import JSONProcessor
|
from cpl_core.utils.json_processor import JSONProcessor
|
||||||
|
|
||||||
|
|
||||||
@ -278,7 +278,9 @@ class Configuration(ConfigurationABC):
|
|||||||
config_from_file = self._load_json_file(file_path, output)
|
config_from_file = self._load_json_file(file_path, output)
|
||||||
for sub in ConfigurationModelABC.__subclasses__():
|
for sub in ConfigurationModelABC.__subclasses__():
|
||||||
for key, value in config_from_file.items():
|
for key, value in config_from_file.items():
|
||||||
if sub.__name__ == key or sub.__name__.replace("Settings", "") == key:
|
if sub.__name__ != key and sub.__name__.replace("Settings", "") != key:
|
||||||
|
continue
|
||||||
|
|
||||||
configuration = sub()
|
configuration = sub()
|
||||||
from_dict = getattr(configuration, "from_dict", None)
|
from_dict = getattr(configuration, "from_dict", None)
|
||||||
|
|
||||||
@ -294,7 +296,7 @@ class Configuration(ConfigurationABC):
|
|||||||
|
|
||||||
self.add_configuration(sub, configuration)
|
self.add_configuration(sub, configuration)
|
||||||
|
|
||||||
def add_configuration(self, key_type: Type[T], value: any):
|
def add_configuration(self, key_type: T, value: any):
|
||||||
self._config[key_type] = value
|
self._config[key_type] = value
|
||||||
|
|
||||||
def create_console_argument(
|
def create_console_argument(
|
||||||
@ -314,7 +316,7 @@ class Configuration(ConfigurationABC):
|
|||||||
for arg in self._argument_types:
|
for arg in self._argument_types:
|
||||||
call(arg)
|
call(arg)
|
||||||
|
|
||||||
def get_configuration(self, search_type: T) -> Optional[T]:
|
def get_configuration(self, search_type: T) -> Optional[R]:
|
||||||
if type(search_type) is str:
|
if type(search_type) is str:
|
||||||
if search_type == ConfigurationVariableNameEnum.environment.value:
|
if search_type == ConfigurationVariableNameEnum.environment.value:
|
||||||
return self._application_environment.environment_name
|
return self._application_environment.environment_name
|
||||||
@ -343,7 +345,7 @@ class Configuration(ConfigurationABC):
|
|||||||
executables: list[ExecutableArgument] = []
|
executables: list[ExecutableArgument] = []
|
||||||
self._parse_arguments(executables, arg_list, self._argument_types)
|
self._parse_arguments(executables, arg_list, self._argument_types)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error("An error occurred while parsing arguments.")
|
Console.error("An error occurred while parsing arguments.", traceback.format_exc())
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -355,7 +357,7 @@ class Configuration(ConfigurationABC):
|
|||||||
if exe.validators is not None:
|
if exe.validators is not None:
|
||||||
abort = False
|
abort = False
|
||||||
for validator_type in exe.validators:
|
for validator_type in exe.validators:
|
||||||
validator: ValidatorABC = services.get_service(validator_type)
|
validator = services.get_service(validator_type)
|
||||||
result = validator.validate()
|
result = validator.validate()
|
||||||
abort = not result
|
abort = not result
|
||||||
if abort:
|
if abort:
|
||||||
@ -364,7 +366,7 @@ class Configuration(ConfigurationABC):
|
|||||||
if abort:
|
if abort:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
cmd: ArgumentExecutableABC = services.get_service(exe.executable_type)
|
cmd = services.get_service(exe.executable_type)
|
||||||
self._handle_pre_or_post_executables(True, exe, services)
|
self._handle_pre_or_post_executables(True, exe, services)
|
||||||
self._set_variable("ACTIVE_EXECUTABLE", exe.name)
|
self._set_variable("ACTIVE_EXECUTABLE", exe.name)
|
||||||
args = self.get_configuration("ARGS")
|
args = self.get_configuration("ARGS")
|
||||||
|
@ -6,7 +6,7 @@ from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
|||||||
from cpl_core.configuration.argument_abc import ArgumentABC
|
from cpl_core.configuration.argument_abc import ArgumentABC
|
||||||
from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum
|
from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum
|
||||||
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||||
from cpl_core.type import T
|
from cpl_core.type import T, R
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationABC(ABC):
|
class ConfigurationABC(ABC):
|
||||||
@ -77,11 +77,11 @@ class ConfigurationABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_configuration(self, key_type: Type[T], value: any):
|
def add_configuration(self, key_type: T, value: any):
|
||||||
r"""Add configuration object
|
r"""Add configuration object
|
||||||
|
|
||||||
Parameter:
|
Parameter:
|
||||||
key_type: Union[:class:`str`, :class:`type`]
|
key_type: :class:`cpl_core.type.T`
|
||||||
Type of the value
|
Type of the value
|
||||||
value: any
|
value: any
|
||||||
Object of the value
|
Object of the value
|
||||||
@ -124,11 +124,11 @@ class ConfigurationABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_configuration(self, search_type: Type[T]) -> Optional[T]:
|
def get_configuration(self, search_type: T) -> Optional[R]:
|
||||||
r"""Returns value from configuration by given type
|
r"""Returns value from configuration by given type
|
||||||
|
|
||||||
Parameter:
|
Parameter:
|
||||||
search_type: Union[:class:`str`, Type[:class:`cpl_core.configuration.configuration_model_abc.ConfigurationModelABC`]]
|
search_type: :class:`cpl_core.type.T`
|
||||||
Type to search for
|
Type to search for
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.console"
|
__title__ = "cpl_core.console"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .foreground_color_enum import ForegroundColorEnum
|
|||||||
from .spinner_thread import SpinnerThread
|
from .spinner_thread import SpinnerThread
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -2,31 +2,31 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "cpl-core",
|
"Name": "cpl-core",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2023",
|
"Major": "2024",
|
||||||
"Minor": "4",
|
"Minor": "7",
|
||||||
"Micro": "dev170"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
"Description": "CPL core",
|
"Description": "CPL core",
|
||||||
"LongDescription": "CPL core package",
|
"LongDescription": "CPL core package",
|
||||||
"URL": "https://www.sh-edraft.de",
|
"URL": "https://www.sh-edraft.de",
|
||||||
"CopyrightDate": "2020 - 2023",
|
"CopyrightDate": "2020 - 2024",
|
||||||
"CopyrightName": "sh-edraft.de",
|
"CopyrightName": "sh-edraft.de",
|
||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"art>=5.9",
|
"art>=6.2",
|
||||||
"colorama>=0.4.6",
|
"colorama>=0.4.6",
|
||||||
"mysql-connector>=2.2.9",
|
"psutil>=6.0.0",
|
||||||
"psutil>=5.9.4",
|
"packaging>=24.1",
|
||||||
"packaging>=23.0",
|
|
||||||
"pynput>=1.7.6",
|
"pynput>=1.7.6",
|
||||||
"setuptools>=67.6.1",
|
"setuptools>=70.1.0",
|
||||||
"tabulate>=0.9.0",
|
"tabulate>=0.9.0",
|
||||||
"termcolor>=2.2.0",
|
"termcolor>=2.4.0",
|
||||||
"watchdog>=3.0.0",
|
"watchdog>=4.0.1",
|
||||||
"wheel>=0.40.0"
|
"wheel>=0.43.0",
|
||||||
|
"mysql-connector-python>=8.4.0"
|
||||||
],
|
],
|
||||||
"DevDependencies": [
|
"DevDependencies": [
|
||||||
"Sphinx==5.0.2",
|
"Sphinx==5.0.2",
|
||||||
@ -36,7 +36,7 @@
|
|||||||
"sphinx-markdown-builder==0.5.5",
|
"sphinx-markdown-builder==0.5.5",
|
||||||
"pygount==1.5.1"
|
"pygount==1.5.1"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10",
|
"PythonVersion": ">=3.12",
|
||||||
"PythonPath": {},
|
"PythonPath": {},
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.database"
|
__title__ = "cpl_core.database"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -26,4 +26,4 @@ from .database_settings import DatabaseSettings
|
|||||||
from .table_abc import TableABC
|
from .table_abc import TableABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.database.connection"
|
__title__ = "cpl_core.database.connection"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .database_connection import DatabaseConnection
|
|||||||
from .database_connection_abc import DatabaseConnectionABC
|
from .database_connection_abc import DatabaseConnectionABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import mysql.connector as sql
|
import mysql.connector as sql
|
||||||
|
from mysql.connector.abstracts import MySQLConnectionAbstract
|
||||||
|
from mysql.connector.cursor import MySQLCursorBuffered
|
||||||
|
|
||||||
from cpl_core.database.connection.database_connection_abc import DatabaseConnectionABC
|
from cpl_core.database.connection.database_connection_abc import DatabaseConnectionABC
|
||||||
from cpl_core.database.database_settings import DatabaseSettings
|
from cpl_core.database.database_settings import DatabaseSettings
|
||||||
from cpl_core.utils.credential_manager import CredentialManager
|
from cpl_core.utils.credential_manager import CredentialManager
|
||||||
from mysql.connector.abstracts import MySQLConnectionAbstract
|
|
||||||
from mysql.connector.cursor import MySQLCursorBuffered
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseConnection(DatabaseConnectionABC):
|
class DatabaseConnection(DatabaseConnectionABC):
|
||||||
@ -25,27 +26,29 @@ class DatabaseConnection(DatabaseConnectionABC):
|
|||||||
def cursor(self) -> MySQLCursorBuffered:
|
def cursor(self) -> MySQLCursorBuffered:
|
||||||
return self._cursor
|
return self._cursor
|
||||||
|
|
||||||
def connect(self, database_settings: DatabaseSettings):
|
def connect(self, settings: DatabaseSettings):
|
||||||
connection = sql.connect(
|
connection = sql.connect(
|
||||||
host=database_settings.host,
|
host=settings.host,
|
||||||
port=database_settings.port,
|
port=settings.port,
|
||||||
user=database_settings.user,
|
user=settings.user,
|
||||||
passwd=CredentialManager.decrypt(database_settings.password),
|
passwd=CredentialManager.decrypt(settings.password),
|
||||||
charset=database_settings.charset,
|
charset=settings.charset,
|
||||||
use_unicode=database_settings.use_unicode,
|
use_unicode=settings.use_unicode,
|
||||||
buffered=database_settings.buffered,
|
buffered=settings.buffered,
|
||||||
auth_plugin=database_settings.auth_plugin,
|
auth_plugin=settings.auth_plugin,
|
||||||
|
ssl_disabled=settings.ssl_disabled,
|
||||||
)
|
)
|
||||||
connection.cursor().execute(f"CREATE DATABASE IF NOT EXISTS `{database_settings.database}`;")
|
connection.cursor().execute(f"CREATE DATABASE IF NOT EXISTS `{settings.database}`;")
|
||||||
self._database = sql.connect(
|
self._database = sql.connect(
|
||||||
host=database_settings.host,
|
host=settings.host,
|
||||||
port=database_settings.port,
|
port=settings.port,
|
||||||
user=database_settings.user,
|
user=settings.user,
|
||||||
passwd=CredentialManager.decrypt(database_settings.password),
|
passwd=CredentialManager.decrypt(settings.password),
|
||||||
db=database_settings.database,
|
db=settings.database,
|
||||||
charset=database_settings.charset,
|
charset=settings.charset,
|
||||||
use_unicode=database_settings.use_unicode,
|
use_unicode=settings.use_unicode,
|
||||||
buffered=database_settings.buffered,
|
buffered=settings.buffered,
|
||||||
auth_plugin=database_settings.auth_plugin,
|
auth_plugin=settings.auth_plugin,
|
||||||
|
ssl_disabled=settings.ssl_disabled,
|
||||||
)
|
)
|
||||||
self._cursor = self._database.cursor()
|
self._cursor = self._database.cursor()
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.database.context"
|
__title__ = "cpl_core.database.context"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .database_context import DatabaseContext
|
|||||||
from .database_context_abc import DatabaseContextABC
|
from .database_context_abc import DatabaseContextABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -21,7 +21,6 @@ class DatabaseContext(DatabaseContextABC):
|
|||||||
DatabaseContextABC.__init__(self)
|
DatabaseContextABC.__init__(self)
|
||||||
|
|
||||||
self._db: DatabaseConnectionABC = DatabaseConnection()
|
self._db: DatabaseConnectionABC = DatabaseConnection()
|
||||||
self._tables: list[TableABC] = TableABC.__subclasses__()
|
|
||||||
self._settings: Optional[DatabaseSettings] = None
|
self._settings: Optional[DatabaseSettings] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -32,7 +31,7 @@ class DatabaseContext(DatabaseContextABC):
|
|||||||
def _ping_and_reconnect(self):
|
def _ping_and_reconnect(self):
|
||||||
try:
|
try:
|
||||||
self._db.server.ping(reconnect=True, attempts=3, delay=5)
|
self._db.server.ping(reconnect=True, attempts=3, delay=5)
|
||||||
except mysql.connector.Error as err:
|
except Exception as err:
|
||||||
# reconnect your cursor as you did in __init__ or wherever
|
# reconnect your cursor as you did in __init__ or wherever
|
||||||
if self._settings is None:
|
if self._settings is None:
|
||||||
raise Exception("Call DatabaseContext.connect first")
|
raise Exception("Call DatabaseContext.connect first")
|
||||||
@ -42,8 +41,6 @@ class DatabaseContext(DatabaseContextABC):
|
|||||||
if self._settings is None:
|
if self._settings is None:
|
||||||
self._settings = database_settings
|
self._settings = database_settings
|
||||||
self._db.connect(database_settings)
|
self._db.connect(database_settings)
|
||||||
for table in self._tables:
|
|
||||||
self._db.cursor.execute(table.get_create_string())
|
|
||||||
|
|
||||||
self.save_changes()
|
self.save_changes()
|
||||||
|
|
||||||
|
@ -9,14 +9,15 @@ class DatabaseSettings(ConfigurationModelABC):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
host: str = None,
|
host: str = None,
|
||||||
port: int = None,
|
port: int = 3306,
|
||||||
user: str = None,
|
user: str = None,
|
||||||
password: str = None,
|
password: str = None,
|
||||||
database: str = None,
|
database: str = None,
|
||||||
charset: str = None,
|
charset: str = "utf8mb4",
|
||||||
use_unicode: bool = None,
|
use_unicode: bool = False,
|
||||||
buffered: bool = None,
|
buffered: bool = False,
|
||||||
auth_plugin: str = None,
|
auth_plugin: str = "caching_sha2_password",
|
||||||
|
ssl_disabled: bool = False,
|
||||||
):
|
):
|
||||||
ConfigurationModelABC.__init__(self)
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
@ -24,11 +25,12 @@ class DatabaseSettings(ConfigurationModelABC):
|
|||||||
self._port: Optional[int] = port
|
self._port: Optional[int] = port
|
||||||
self._user: Optional[str] = user
|
self._user: Optional[str] = user
|
||||||
self._password: Optional[str] = password
|
self._password: Optional[str] = password
|
||||||
self._databse: Optional[str] = database
|
self._database: Optional[str] = database
|
||||||
self._charset: Optional[str] = charset
|
self._charset: Optional[str] = charset
|
||||||
self._use_unicode: Optional[bool] = use_unicode
|
self._use_unicode: Optional[bool] = use_unicode
|
||||||
self._buffered: Optional[bool] = buffered
|
self._buffered: Optional[bool] = buffered
|
||||||
self._auth_plugin: Optional[str] = auth_plugin
|
self._auth_plugin: Optional[str] = auth_plugin
|
||||||
|
self._ssl_disabled: Optional[bool] = ssl_disabled
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self) -> Optional[str]:
|
def host(self) -> Optional[str]:
|
||||||
@ -48,7 +50,7 @@ class DatabaseSettings(ConfigurationModelABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def database(self) -> Optional[str]:
|
def database(self) -> Optional[str]:
|
||||||
return self._databse
|
return self._database
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def charset(self) -> Optional[str]:
|
def charset(self) -> Optional[str]:
|
||||||
@ -65,3 +67,7 @@ class DatabaseSettings(ConfigurationModelABC):
|
|||||||
@property
|
@property
|
||||||
def auth_plugin(self) -> Optional[str]:
|
def auth_plugin(self) -> Optional[str]:
|
||||||
return self._auth_plugin
|
return self._auth_plugin
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ssl_disabled(self) -> Optional[bool]:
|
||||||
|
return self._ssl_disabled
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.dependency_injection"
|
__title__ = "cpl_core.dependency_injection"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ from .service_provider import ServiceProvider
|
|||||||
from .service_provider_abc import ServiceProviderABC
|
from .service_provider_abc import ServiceProviderABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -61,15 +61,15 @@ class ServiceCollection(ServiceCollectionABC):
|
|||||||
self.add_transient(PipeABC, pipe)
|
self.add_transient(PipeABC, pipe)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def add_singleton(self, service_type: Type[T], service: T = None):
|
def add_singleton(self, service_type: T, service: T = None):
|
||||||
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.singleton, service)
|
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.singleton, service)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def add_scoped(self, service_type: Type[T], service: Callable = None):
|
def add_scoped(self, service_type: T, service: T = None):
|
||||||
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.scoped, service)
|
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.scoped, service)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def add_transient(self, service_type: Type[T], service: T = None):
|
def add_transient(self, service_type: T, service: T = None):
|
||||||
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.transient, service)
|
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.transient, service)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class ServiceCollectionABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_transient(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC":
|
def add_transient(self, service_type: T, service: T = None) -> "ServiceCollectionABC":
|
||||||
r"""Adds a service with transient lifetime
|
r"""Adds a service with transient lifetime
|
||||||
|
|
||||||
Parameter:
|
Parameter:
|
||||||
@ -61,7 +61,7 @@ class ServiceCollectionABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_scoped(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC":
|
def add_scoped(self, service_type: T, service: T = None) -> "ServiceCollectionABC":
|
||||||
r"""Adds a service with scoped lifetime
|
r"""Adds a service with scoped lifetime
|
||||||
|
|
||||||
Parameter:
|
Parameter:
|
||||||
@ -76,7 +76,7 @@ class ServiceCollectionABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_singleton(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC":
|
def add_singleton(self, service_type: T, service: T = None) -> "ServiceCollectionABC":
|
||||||
r"""Adds a service with singleton lifetime
|
r"""Adds a service with singleton lifetime
|
||||||
|
|
||||||
Parameter:
|
Parameter:
|
||||||
|
@ -12,7 +12,7 @@ from cpl_core.dependency_injection.service_descriptor import ServiceDescriptor
|
|||||||
from cpl_core.dependency_injection.service_lifetime_enum import ServiceLifetimeEnum
|
from cpl_core.dependency_injection.service_lifetime_enum import ServiceLifetimeEnum
|
||||||
from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC
|
from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||||
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||||
from cpl_core.type import T
|
from cpl_core.type import T, R
|
||||||
|
|
||||||
|
|
||||||
class ServiceProvider(ServiceProviderABC):
|
class ServiceProvider(ServiceProviderABC):
|
||||||
@ -80,7 +80,7 @@ class ServiceProvider(ServiceProviderABC):
|
|||||||
|
|
||||||
return implementations
|
return implementations
|
||||||
|
|
||||||
def build_by_signature(self, sig: Signature) -> list[T]:
|
def build_by_signature(self, sig: Signature) -> list[R]:
|
||||||
params = []
|
params = []
|
||||||
for param in sig.parameters.items():
|
for param in sig.parameters.items():
|
||||||
parameter = param[1]
|
parameter = param[1]
|
||||||
@ -138,7 +138,7 @@ class ServiceProvider(ServiceProviderABC):
|
|||||||
sb = ScopeBuilder(ServiceProvider(descriptors, self._configuration, self._database_context))
|
sb = ScopeBuilder(ServiceProvider(descriptors, self._configuration, self._database_context))
|
||||||
return sb.build()
|
return sb.build()
|
||||||
|
|
||||||
def get_service(self, service_type: typing.Type[T], *args, **kwargs) -> Optional[T]:
|
def get_service(self, service_type: T, *args, **kwargs) -> Optional[R]:
|
||||||
result = self._find_service(service_type)
|
result = self._find_service(service_type)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
@ -157,12 +157,12 @@ class ServiceProvider(ServiceProviderABC):
|
|||||||
|
|
||||||
return implementation
|
return implementation
|
||||||
|
|
||||||
def get_services(self, service_type: typing.Type[T], *args, **kwargs) -> list[Optional[T]]:
|
def get_services(self, service_type: T, *args, **kwargs) -> list[Optional[R]]:
|
||||||
implementations = []
|
implementations = []
|
||||||
|
|
||||||
if typing.get_origin(service_type) != list:
|
if typing.get_origin(service_type) == list:
|
||||||
raise Exception(f"Invalid type {service_type}! Expected list of type")
|
raise Exception(f"Invalid type {service_type}! Expected single type not list of type")
|
||||||
|
|
||||||
implementations.extend(self._get_services(typing.get_args(service_type)[0]))
|
implementations.extend(self._get_services(service_type))
|
||||||
|
|
||||||
return implementations
|
return implementations
|
||||||
|
@ -4,7 +4,7 @@ from inspect import Signature, signature
|
|||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
from cpl_core.dependency_injection.scope_abc import ScopeABC
|
from cpl_core.dependency_injection.scope_abc import ScopeABC
|
||||||
from cpl_core.type import T
|
from cpl_core.type import T, R
|
||||||
|
|
||||||
|
|
||||||
class ServiceProviderABC(ABC):
|
class ServiceProviderABC(ABC):
|
||||||
@ -21,7 +21,7 @@ class ServiceProviderABC(ABC):
|
|||||||
cls._provider = provider
|
cls._provider = provider
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def build_by_signature(self, sig: Signature) -> list[T]:
|
def build_by_signature(self, sig: Signature) -> list[R]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@ -61,7 +61,7 @@ class ServiceProviderABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_service(self, instance_type: Type[T], *args, **kwargs) -> Optional[T]:
|
def get_service(self, instance_type: T, *args, **kwargs) -> Optional[R]:
|
||||||
r"""Returns instance of given type
|
r"""Returns instance of given type
|
||||||
|
|
||||||
Parameter
|
Parameter
|
||||||
@ -76,12 +76,12 @@ class ServiceProviderABC(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_services(self, service_type: Type[T], *args, **kwargs) -> list[Optional[T]]:
|
def get_services(self, service_type: T, *args, **kwargs) -> list[Optional[R]]:
|
||||||
r"""Returns instance of given type
|
r"""Returns instance of given type
|
||||||
|
|
||||||
Parameter
|
Parameter
|
||||||
---------
|
---------
|
||||||
instance_type: :class:`cpl_core.type.T`
|
service_type: :class:`cpl_core.type.T`
|
||||||
The type of the searched instance
|
The type of the searched instance
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.environment"
|
__title__ = "cpl_core.environment"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -26,4 +26,4 @@ from .environment_name_enum import EnvironmentNameEnum
|
|||||||
from .application_environment import ApplicationEnvironment
|
from .application_environment import ApplicationEnvironment
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.logging"
|
__title__ = "cpl_core.logging"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .logging_settings import LoggingSettings
|
|||||||
from .logging_settings_name_enum import LoggingSettingsNameEnum
|
from .logging_settings_name_enum import LoggingSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.mailing"
|
__title__ = "cpl_core.mailing"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .email_client_settings import EMailClientSettings
|
|||||||
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
|
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.pipes"
|
__title__ = "cpl_core.pipes"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -26,4 +26,4 @@ from .ip_address_pipe import IPAddressPipe
|
|||||||
from .pipe_abc import PipeABC
|
from .pipe_abc import PipeABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.time"
|
__title__ = "cpl_core.time"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .time_format_settings import TimeFormatSettings
|
|||||||
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
|
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import TypeVar, Union
|
from typing import TypeVar
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
Number = Union[int, float]
|
R = TypeVar("R")
|
||||||
|
@ -6,7 +6,7 @@ cpl-core CPL core
|
|||||||
|
|
||||||
CPL core package
|
CPL core package
|
||||||
|
|
||||||
:copyright: (c) 2020 - 2023 sh-edraft.de
|
:copyright: (c) 2020 - 2024 sh-edraft.de
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14,8 +14,8 @@ CPL core package
|
|||||||
__title__ = "cpl_core.utils"
|
__title__ = "cpl_core.utils"
|
||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2020 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2020 - 2024 sh-edraft.de"
|
||||||
__version__ = "2023.4.dev170"
|
__version__ = "2024.6.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -26,4 +26,4 @@ from .string import String
|
|||||||
from .pip import Pip
|
from .pip import Pip
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2024", minor="6", micro="0")
|
||||||
|
@ -8,6 +8,7 @@ class JSONProcessor:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def process(_t: type, values: dict) -> object:
|
def process(_t: type, values: dict) -> object:
|
||||||
args = []
|
args = []
|
||||||
|
kwargs = {}
|
||||||
|
|
||||||
sig = signature(_t.__init__)
|
sig = signature(_t.__init__)
|
||||||
for param in sig.parameters.items():
|
for param in sig.parameters.items():
|
||||||
@ -21,10 +22,13 @@ class JSONProcessor:
|
|||||||
value = ""
|
value = ""
|
||||||
if name in values:
|
if name in values:
|
||||||
value = values[name]
|
value = values[name]
|
||||||
|
values.pop(name)
|
||||||
elif name_first_lower in values:
|
elif name_first_lower in values:
|
||||||
value = values[name_first_lower]
|
value = values[name_first_lower]
|
||||||
|
values.pop(name_first_lower)
|
||||||
else:
|
else:
|
||||||
value = values[name.upper()]
|
value = values[name.upper()]
|
||||||
|
values.pop(name.upper())
|
||||||
|
|
||||||
if isinstance(value, dict) and not issubclass(parameter.annotation, dict):
|
if isinstance(value, dict) and not issubclass(parameter.annotation, dict):
|
||||||
value = JSONProcessor.process(parameter.annotation, value)
|
value = JSONProcessor.process(parameter.annotation, value)
|
||||||
@ -37,10 +41,13 @@ class JSONProcessor:
|
|||||||
|
|
||||||
args.append(value)
|
args.append(value)
|
||||||
|
|
||||||
|
elif parameter.name == "kwargs" and parameter.annotation == dict:
|
||||||
|
kwargs = values
|
||||||
|
|
||||||
elif parameter.default != Parameter.empty:
|
elif parameter.default != Parameter.empty:
|
||||||
args.append(parameter.default)
|
args.append(parameter.default)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
args.append(None)
|
args.append(None)
|
||||||
|
|
||||||
return _t(*args)
|
return _t(*args, **kwargs)
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -59,4 +59,4 @@ def get_discord_collection(services: "ServiceCollectionABC") -> "DiscordCollecti
|
|||||||
# build-ignore-end
|
# build-ignore-end
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.application"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -24,4 +24,4 @@ from collections import namedtuple
|
|||||||
from .discord_bot_application_abc import DiscordBotApplicationABC
|
from .discord_bot_application_abc import DiscordBotApplicationABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.command"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .discord_command_abc import DiscordCommandABC
|
|||||||
from .discord_commands_meta import DiscordCogMeta
|
from .discord_commands_meta import DiscordCogMeta
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.configuration"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -24,4 +24,4 @@ from collections import namedtuple
|
|||||||
from .discord_bot_settings import DiscordBotSettings
|
from .discord_bot_settings import DiscordBotSettings
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.container"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ from .thread import Thread
|
|||||||
from .voice_channel import VoiceChannel
|
from .voice_channel import VoiceChannel
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -4,7 +4,7 @@ from cpl_discord.container.container import Container
|
|||||||
from cpl_discord.container.text_channel import TextChannel
|
from cpl_discord.container.text_channel import TextChannel
|
||||||
from cpl_discord.container.voice_channel import VoiceChannel
|
from cpl_discord.container.voice_channel import VoiceChannel
|
||||||
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class CategoryChannel(discord.CategoryChannel, Container):
|
class CategoryChannel(discord.CategoryChannel, Container):
|
||||||
|
@ -7,7 +7,7 @@ from cpl_discord.container.role import Role
|
|||||||
from cpl_discord.container.text_channel import TextChannel
|
from cpl_discord.container.text_channel import TextChannel
|
||||||
from cpl_discord.container.voice_channel import VoiceChannel
|
from cpl_discord.container.voice_channel import VoiceChannel
|
||||||
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class Guild(Container, discord.Guild):
|
class Guild(Container, discord.Guild):
|
||||||
|
@ -4,7 +4,7 @@ from cpl_discord.container.container import Container
|
|||||||
from cpl_discord.container.member import Member
|
from cpl_discord.container.member import Member
|
||||||
from cpl_discord.container.thread import Thread
|
from cpl_discord.container.thread import Thread
|
||||||
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class TextChannel(discord.TextChannel, Container):
|
class TextChannel(discord.TextChannel, Container):
|
||||||
|
@ -3,7 +3,7 @@ import discord
|
|||||||
from cpl_discord.container.container import Container
|
from cpl_discord.container.container import Container
|
||||||
from cpl_discord.container.member import Member
|
from cpl_discord.container.member import Member
|
||||||
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class Thread(discord.Thread, Container):
|
class Thread(discord.Thread, Container):
|
||||||
|
@ -3,7 +3,7 @@ import discord
|
|||||||
from cpl_discord.container.container import Container
|
from cpl_discord.container.container import Container
|
||||||
from cpl_discord.container.member import Member
|
from cpl_discord.container.member import Member
|
||||||
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
from cpl_discord.helper.to_containers_converter import ToContainersConverter
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class VoiceChannel(discord.VoiceChannel, Container):
|
class VoiceChannel(discord.VoiceChannel, Container):
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "cpl-discord",
|
"Name": "cpl-discord",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2023",
|
"Major": "2024",
|
||||||
"Minor": "4",
|
"Minor": "7",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
@ -16,12 +16,12 @@
|
|||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core>=2023.4.0",
|
"cpl-core>=2024.6.2024.07.0",
|
||||||
"discord.py>=2.2.2",
|
"discord.py>=2.3.2",
|
||||||
"cpl-query>=2023.4.0"
|
"cpl-query>=2024.6.2024.07.0"
|
||||||
],
|
],
|
||||||
"DevDependencies": [
|
"DevDependencies": [
|
||||||
"cpl-cli>=2023.4.0"
|
"cpl-cli>=2024.6.2024.07.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10",
|
"PythonVersion": ">=3.10",
|
||||||
"PythonPath": {},
|
"PythonPath": {},
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.events"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -69,4 +69,4 @@ from .on_voice_state_update_abc import OnVoiceStateUpdateABC
|
|||||||
from .on_webhooks_update_abc import OnWebhooksUpdateABC
|
from .on_webhooks_update_abc import OnWebhooksUpdateABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.helper"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -24,4 +24,4 @@ from collections import namedtuple
|
|||||||
from .to_containers_converter import ToContainersConverter
|
from .to_containers_converter import ToContainersConverter
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_discord.service"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0.post1"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -29,4 +29,4 @@ from .discord_service import DiscordService
|
|||||||
from .discord_service_abc import DiscordServiceABC
|
from .discord_service_abc import DiscordServiceABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0.post1")
|
||||||
|
@ -56,14 +56,13 @@ class DiscordBotService(DiscordBotServiceABC):
|
|||||||
env_token = self._config.get_configuration("TOKEN")
|
env_token = self._config.get_configuration("TOKEN")
|
||||||
env_prefix = self._config.get_configuration("PREFIX")
|
env_prefix = self._config.get_configuration("PREFIX")
|
||||||
|
|
||||||
new_settings.from_dict(
|
new_settings = DiscordBotSettings(
|
||||||
{
|
env_token if token is None or token == "" else token,
|
||||||
"Token": env_token if token is None or token == "" else token,
|
("! " if self._is_string_invalid(env_prefix) else env_prefix)
|
||||||
"Prefix": ("! " if self._is_string_invalid(env_prefix) else env_prefix)
|
|
||||||
if self._is_string_invalid(prefix)
|
if self._is_string_invalid(prefix)
|
||||||
else prefix,
|
else prefix,
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if new_settings.token is None or new_settings.token == "":
|
if new_settings.token is None or new_settings.token == "":
|
||||||
raise Exception("You have to configure discord token by appsettings or environment variables")
|
raise Exception("You have to configure discord token by appsettings or environment variables")
|
||||||
return new_settings
|
return new_settings
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
from typing import Type, Optional
|
from typing import Type
|
||||||
|
|
||||||
|
from cpl_core.console import Console, ForegroundColorEnum
|
||||||
from cpl_core.dependency_injection import ServiceCollectionABC
|
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||||
from cpl_discord.command.discord_command_abc import DiscordCommandABC
|
from cpl_discord.command.discord_command_abc import DiscordCommandABC
|
||||||
from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum
|
from cpl_discord.discord_event_types_enum import DiscordEventTypesEnum
|
||||||
from cpl_discord.service.command_error_handler_service import CommandErrorHandlerService
|
from cpl_discord.service.command_error_handler_service import CommandErrorHandlerService
|
||||||
from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
|
from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
|
||||||
from cpl_query.extension import List
|
|
||||||
|
|
||||||
|
|
||||||
class DiscordCollection(DiscordCollectionABC):
|
class DiscordCollection(DiscordCollectionABC):
|
||||||
@ -13,26 +13,21 @@ class DiscordCollection(DiscordCollectionABC):
|
|||||||
DiscordCollectionABC.__init__(self)
|
DiscordCollectionABC.__init__(self)
|
||||||
|
|
||||||
self._services = service_collection
|
self._services = service_collection
|
||||||
self._events: dict[str, List] = {}
|
|
||||||
self._commands = List(type(DiscordCommandABC))
|
|
||||||
|
|
||||||
self.add_event(DiscordEventTypesEnum.on_command_error.value, CommandErrorHandlerService)
|
self._services.add_transient(DiscordEventTypesEnum.on_command_error.value, CommandErrorHandlerService)
|
||||||
|
|
||||||
def add_command(self, _t: Type[DiscordCommandABC]):
|
def add_command(self, _t: Type[DiscordCommandABC]):
|
||||||
|
Console.set_foreground_color(ForegroundColorEnum.yellow)
|
||||||
|
Console.write_line(
|
||||||
|
f"{type(self).__name__}.add_command is deprecated. Instead, use ServiceCollection.add_transient directly!"
|
||||||
|
)
|
||||||
|
Console.color_reset()
|
||||||
self._services.add_transient(DiscordCommandABC, _t)
|
self._services.add_transient(DiscordCommandABC, _t)
|
||||||
self._commands.append(_t)
|
|
||||||
|
|
||||||
def get_commands(self) -> List[DiscordCommandABC]:
|
|
||||||
return self._commands
|
|
||||||
|
|
||||||
def add_event(self, _t_event: Type, _t: Type):
|
def add_event(self, _t_event: Type, _t: Type):
|
||||||
|
Console.set_foreground_color(ForegroundColorEnum.yellow)
|
||||||
|
Console.write_line(
|
||||||
|
f"{type(self).__name__}.add_event is deprecated. Instead, use ServiceCollection.add_transient directly!"
|
||||||
|
)
|
||||||
|
Console.color_reset()
|
||||||
self._services.add_transient(_t_event, _t)
|
self._services.add_transient(_t_event, _t)
|
||||||
if _t_event not in self._events:
|
|
||||||
self._events[_t_event] = List(type(_t_event))
|
|
||||||
|
|
||||||
self._events[_t_event].append(_t)
|
|
||||||
|
|
||||||
def get_events_by_base(self, _t_event: Type) -> Optional[List]:
|
|
||||||
if _t_event not in self._events:
|
|
||||||
return None
|
|
||||||
return self._events[_t_event]
|
|
||||||
|
@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension.list import List
|
||||||
|
|
||||||
|
|
||||||
class DiscordCollectionABC(ABC):
|
class DiscordCollectionABC(ABC):
|
||||||
@ -13,14 +13,6 @@ class DiscordCollectionABC(ABC):
|
|||||||
def add_command(self, _t: Type[DiscordCommandABC]):
|
def add_command(self, _t: Type[DiscordCommandABC]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def get_commands(self) -> List[DiscordCommandABC]:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def add_event(self, _t_event: Type, _t: Type):
|
def add_event(self, _t_event: Type, _t: Type):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def get_events_by_base(self, _t_event: Type):
|
|
||||||
pass
|
|
||||||
|
@ -4,11 +4,12 @@ from typing import Optional, Sequence, Union, Type
|
|||||||
import discord
|
import discord
|
||||||
from discord import RawReactionActionEvent
|
from discord import RawReactionActionEvent
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import Context, CommandError, Cog, Command
|
from discord.ext.commands import Context, CommandError, Cog
|
||||||
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
from cpl_core.utils import String
|
from cpl_core.utils import String
|
||||||
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.command.discord_commands_meta import DiscordCogMeta
|
from cpl_discord.command.discord_commands_meta import DiscordCogMeta
|
||||||
from cpl_discord.events.on_bulk_message_delete_abc import OnBulkMessageDeleteABC
|
from cpl_discord.events.on_bulk_message_delete_abc import OnBulkMessageDeleteABC
|
||||||
from cpl_discord.events.on_command_abc import OnCommandABC
|
from cpl_discord.events.on_command_abc import OnCommandABC
|
||||||
@ -66,25 +67,17 @@ from cpl_discord.events.on_typing_abc import OnTypingABC
|
|||||||
from cpl_discord.events.on_user_update_abc import OnUserUpdateABC
|
from cpl_discord.events.on_user_update_abc import OnUserUpdateABC
|
||||||
from cpl_discord.events.on_voice_state_update_abc import OnVoiceStateUpdateABC
|
from cpl_discord.events.on_voice_state_update_abc import OnVoiceStateUpdateABC
|
||||||
from cpl_discord.events.on_webhooks_update_abc import OnWebhooksUpdateABC
|
from cpl_discord.events.on_webhooks_update_abc import OnWebhooksUpdateABC
|
||||||
from cpl_discord.service.discord_collection_abc import DiscordCollectionABC
|
|
||||||
from cpl_discord.service.discord_service_abc import DiscordServiceABC
|
from cpl_discord.service.discord_service_abc import DiscordServiceABC
|
||||||
|
|
||||||
|
|
||||||
class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta):
|
class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta):
|
||||||
def __init__(self, logger: LoggerABC, dc_collection: DiscordCollectionABC, services: ServiceProviderABC):
|
def __init__(self, logger: LoggerABC, services: ServiceProviderABC):
|
||||||
DiscordServiceABC.__init__(self)
|
DiscordServiceABC.__init__(self)
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._collection = dc_collection
|
|
||||||
self._services = services
|
self._services = services
|
||||||
|
|
||||||
async def _handle_event(self, event: Type, *args, **kwargs):
|
async def _handle_event(self, event: Type, *args, **kwargs):
|
||||||
event_collection = self._collection.get_events_by_base(event)
|
for event_instance in self._services.get_services(event):
|
||||||
if event_collection is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
for event_type in event_collection:
|
|
||||||
event_instance = self._services.get_service(event_type)
|
|
||||||
|
|
||||||
func_name = event.__name__
|
func_name = event.__name__
|
||||||
if func_name.endswith("ABC"):
|
if func_name.endswith("ABC"):
|
||||||
func_name = func_name.replace("ABC", "")
|
func_name = func_name.replace("ABC", "")
|
||||||
@ -104,11 +97,10 @@ class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta):
|
|||||||
self._logger.error(__name__, f"{type(self).__name__} initialization failed", e)
|
self._logger.error(__name__, f"{type(self).__name__} initialization failed", e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for command_type in self._collection.get_commands():
|
for command in self._services.get_services(DiscordCommandABC):
|
||||||
self._logger.trace(__name__, f"Register command {command_type.__name__}")
|
self._logger.trace(__name__, f"Register command {type(command).__name__}")
|
||||||
command: Cog = self._services.get_service(command_type)
|
|
||||||
if command is None:
|
if command is None:
|
||||||
self._logger.warn(__name__, f"Instance of {command_type.__name__} not found")
|
self._logger.warn(__name__, f"Instance of {type(command).__name__} not found")
|
||||||
continue
|
continue
|
||||||
await bot.add_cog(command)
|
await bot.add_cog(command)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_query"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_query.base"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .queryable_abc import QueryableABC
|
|||||||
from .sequence import Sequence
|
from .sequence import Sequence
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0")
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
|
from cpl_query.base.queryable_abc import QueryableABC
|
||||||
from cpl_query.base.ordered_queryable_abc import OrderedQueryableABC
|
from cpl_query.base.ordered_queryable_abc import OrderedQueryableABC
|
||||||
from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument
|
from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument
|
||||||
from cpl_query.iterable.iterable import Iterable
|
|
||||||
|
|
||||||
|
|
||||||
class OrderedQueryable(OrderedQueryableABC):
|
class OrderedQueryable(OrderedQueryableABC):
|
||||||
r"""Implementation of :class: `cpl_query.base.ordered_queryable_abc.OrderedQueryableABC`"""
|
r"""Implementation of :class: `cpl_query.base.ordered_queryable_abc.OrderedQueryableABC`"""
|
||||||
|
|
||||||
def __init__(self, _t: type, _values: Iterable = None, _func: Callable = None):
|
def __init__(self, _t: type, _values: QueryableABC = None, _func: Callable = None):
|
||||||
OrderedQueryableABC.__init__(self, _t, _values, _func)
|
OrderedQueryableABC.__init__(self, _t, _values, _func)
|
||||||
|
|
||||||
def then_by(self, _func: Callable) -> OrderedQueryableABC:
|
def then_by(self, _func: Callable) -> OrderedQueryableABC:
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "cpl-query",
|
"Name": "cpl-query",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2023",
|
"Major": "2024",
|
||||||
"Minor": "4",
|
"Minor": "7",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_query.enumerable"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .enumerable import Enumerable
|
|||||||
from .enumerable_abc import EnumerableABC
|
from .enumerable_abc import EnumerableABC
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0")
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_query.extension"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -24,4 +24,4 @@ from collections import namedtuple
|
|||||||
from .list import List
|
from .list import List
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0")
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
from typing import Iterator
|
|
||||||
|
|
||||||
from cpl_query.iterable.iterable import Iterable
|
from cpl_query.iterable.iterable import Iterable
|
||||||
|
|
||||||
|
|
||||||
class List(Iterable):
|
class List(Iterable):
|
||||||
r"""Implementation of :class: `cpl_query.extension.iterable.Iterable`"""
|
r"""Implementation of :class: `cpl_query.extension.iterable.Iterable`"""
|
||||||
|
|
||||||
def __init__(self, t: type = None, values: Iterator = None):
|
def __init__(self, t: type = None, values: Iterable = None):
|
||||||
Iterable.__init__(self, t, values)
|
Iterable.__init__(self, t, values)
|
||||||
|
|
||||||
def __getitem__(self, *args):
|
def __getitem__(self, *args):
|
||||||
|
@ -15,7 +15,7 @@ __title__ = "cpl_query.iterable"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2021 - 2023 sh-edraft.de"
|
||||||
__version__ = "2023.4.0"
|
__version__ = "2023.10.0"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .iterable_abc import IterableABC
|
|||||||
from .iterable import Iterable
|
from .iterable import Iterable
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="0")
|
version_info = VersionInfo(major="2023", minor="10", micro="0")
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
cpl-reactive-extensions CPL Simple ReactiveX implementation
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.
|
|
||||||
|
|
||||||
:copyright: (c) 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "cpl_reactive_extensions"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2023 sh-edraft.de"
|
|
||||||
__version__ = "2023.4.dev170"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
cpl-reactive-extensions CPL Simple ReactiveX implementation
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.
|
|
||||||
|
|
||||||
:copyright: (c) 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "cpl_reactive_extensions.abc"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2023 sh-edraft.de"
|
|
||||||
__version__ = "2023.4.dev170"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
|
@ -1,20 +0,0 @@
|
|||||||
from abc import abstractmethod
|
|
||||||
|
|
||||||
from cpl_core.type import T
|
|
||||||
|
|
||||||
|
|
||||||
class Observer:
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def next(self, value: T):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def error(self, ex: Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def complete(self):
|
|
||||||
pass
|
|
@ -1,8 +0,0 @@
|
|||||||
from typing import Any
|
|
||||||
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
|
|
||||||
|
|
||||||
class Operator:
|
|
||||||
def call(self, subscriber: Subscriber, source: Any):
|
|
||||||
pass
|
|
@ -1,10 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
|
|
||||||
from cpl_core.type import T, Number
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
|
|
||||||
|
|
||||||
class SchedulerAction(ABC):
|
|
||||||
@abstractmethod
|
|
||||||
def schedule(self, state: T = None, delay: Number = None) -> Subscription:
|
|
||||||
pass
|
|
@ -1,12 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
from typing import Callable, Optional
|
|
||||||
|
|
||||||
from cpl_core.type import Number, T
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
from cpl_reactive_extensions.abc.scheduler_action import SchedulerAction
|
|
||||||
|
|
||||||
|
|
||||||
class SchedulerLike(ABC):
|
|
||||||
@abstractmethod
|
|
||||||
def schedule(self, work: Callable[[SchedulerAction, Optional[T]], None], delay: Number, state: T) -> Subscription:
|
|
||||||
pass
|
|
@ -1,16 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
from typing import Union, Callable
|
|
||||||
|
|
||||||
from cpl_reactive_extensions.abc.observer import Observer
|
|
||||||
from cpl_reactive_extensions.abc.unsubscribable import Unsubscribable
|
|
||||||
|
|
||||||
|
|
||||||
class Subscribable(ABC):
|
|
||||||
def __init__(self):
|
|
||||||
ABC.__init__(self)
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def subscribe(
|
|
||||||
self, observer_or_next: Union[Callable, Observer], on_error: Callable = None, on_complete: Callable = None
|
|
||||||
) -> Unsubscribable:
|
|
||||||
pass
|
|
@ -1,10 +0,0 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
|
|
||||||
|
|
||||||
class Unsubscribable(ABC):
|
|
||||||
def __init__(self):
|
|
||||||
ABC.__init__(self)
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def unsubscribe(self):
|
|
||||||
pass
|
|
@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"ProjectSettings": {
|
|
||||||
"Name": "cpl-reactive-extensions",
|
|
||||||
"Version": {
|
|
||||||
"Major": "2023",
|
|
||||||
"Minor": "4",
|
|
||||||
"Micro": "dev170"
|
|
||||||
},
|
|
||||||
"Author": "Sven Heidemann",
|
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
|
||||||
"Description": "CPL Simple ReactiveX implementation",
|
|
||||||
"LongDescription": "CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.",
|
|
||||||
"URL": "https://www.sh-edraft.de",
|
|
||||||
"CopyrightDate": "2023",
|
|
||||||
"CopyrightName": "sh-edraft.de",
|
|
||||||
"LicenseName": "MIT",
|
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
|
||||||
"Dependencies": [
|
|
||||||
"cpl-core>=2023.4.dev170"
|
|
||||||
],
|
|
||||||
"DevDependencies": [
|
|
||||||
"cpl-cli>=2023.4.0"
|
|
||||||
],
|
|
||||||
"PythonVersion": ">=3.10.4",
|
|
||||||
"PythonPath": {},
|
|
||||||
"Classifiers": []
|
|
||||||
},
|
|
||||||
"BuildSettings": {
|
|
||||||
"ProjectType": "library",
|
|
||||||
"SourcePath": "",
|
|
||||||
"OutputPath": "../../dist",
|
|
||||||
"Main": "",
|
|
||||||
"EntryPoint": "",
|
|
||||||
"IncludePackageData": false,
|
|
||||||
"Included": [],
|
|
||||||
"Excluded": [
|
|
||||||
"*/__pycache__",
|
|
||||||
"*/logs",
|
|
||||||
"*/tests"
|
|
||||||
],
|
|
||||||
"PackageData": {},
|
|
||||||
"ProjectReferences": []
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
cpl-reactive-extensions CPL Simple ReactiveX implementation
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.
|
|
||||||
|
|
||||||
:copyright: (c) 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "cpl_reactive_extensions.helper"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2023 sh-edraft.de"
|
|
||||||
__version__ = "2023.4.dev170"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports:
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
|
@ -1,11 +0,0 @@
|
|||||||
def bind(instance, func, *args, as_name=None):
|
|
||||||
"""
|
|
||||||
Bind the function *func* to *instance*, with either provided name *as_name*
|
|
||||||
or the existing name of *func*. The provided *func* should accept the
|
|
||||||
instance as the first argument, i.e. "self".
|
|
||||||
"""
|
|
||||||
if as_name is None:
|
|
||||||
as_name = func.__name__
|
|
||||||
bound_method = func.__get__(instance, instance.__class__)
|
|
||||||
setattr(instance, as_name, bound_method)
|
|
||||||
return bound_method
|
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
cpl-reactive-extensions CPL Simple ReactiveX implementation
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.
|
|
||||||
|
|
||||||
:copyright: (c) 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "cpl_reactive_extensions.internal"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2023 sh-edraft.de"
|
|
||||||
__version__ = "2023.4.dev170"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports:
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
|
@ -1,10 +0,0 @@
|
|||||||
from cpl_core.type import T, Number
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
|
|
||||||
|
|
||||||
class Action(Subscription):
|
|
||||||
def __init__(self, scheduler, work):
|
|
||||||
Subscription.__init__(self)
|
|
||||||
|
|
||||||
def schedule(self, state: T = None, delay: Number = 0) -> Subscription:
|
|
||||||
return self
|
|
@ -1,103 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from cpl_core.type import T, Number
|
|
||||||
from cpl_reactive_extensions.internal.action import Action
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
from cpl_reactive_extensions.timer import Timer
|
|
||||||
|
|
||||||
|
|
||||||
class AsyncAction(Action):
|
|
||||||
def __init__(self, scheduler, work):
|
|
||||||
from cpl_reactive_extensions.scheduler.async_scheduler import AsyncScheduler
|
|
||||||
|
|
||||||
Action.__init__(self, scheduler, work)
|
|
||||||
|
|
||||||
self._scheduler: AsyncScheduler = scheduler
|
|
||||||
self._work = work
|
|
||||||
|
|
||||||
self.timer = None
|
|
||||||
self.state: Optional[T] = None
|
|
||||||
self.delay: Number = 0
|
|
||||||
self._pending = False
|
|
||||||
|
|
||||||
def schedule(self, state: T = None, delay: Number = 0) -> Subscription:
|
|
||||||
if self.closed:
|
|
||||||
return self
|
|
||||||
|
|
||||||
self.state = state
|
|
||||||
|
|
||||||
timer = self.timer
|
|
||||||
scheduler = self._scheduler
|
|
||||||
|
|
||||||
if timer is not None:
|
|
||||||
self.timer = self.recycle_async_timer(scheduler, timer, delay)
|
|
||||||
|
|
||||||
self._pending = True
|
|
||||||
self.delay = delay
|
|
||||||
self.timer = self.timer if self.timer is not None else self.request_async_timer(scheduler, delay)
|
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
def request_async_timer(self, scheduler, delay: Number = 0):
|
|
||||||
from cpl_reactive_extensions.scheduler.async_scheduler import AsyncScheduler
|
|
||||||
|
|
||||||
scheduler: AsyncScheduler = scheduler
|
|
||||||
return Timer(delay, lambda: scheduler.flush(self))
|
|
||||||
|
|
||||||
def recycle_async_timer(self, scheduler, timer=None, delay: Number = None):
|
|
||||||
from cpl_reactive_extensions.scheduler.async_scheduler import AsyncScheduler
|
|
||||||
|
|
||||||
scheduler: AsyncScheduler = scheduler
|
|
||||||
if delay is None and self.delay == delay and not self._pending:
|
|
||||||
return timer
|
|
||||||
|
|
||||||
if timer is not None:
|
|
||||||
timer.clear()
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def execute(self, state: T, delay: Number):
|
|
||||||
if self.closed:
|
|
||||||
return Exception("Executing cancelled action")
|
|
||||||
|
|
||||||
self._pending = False
|
|
||||||
error = self._execute(state, delay)
|
|
||||||
if error is not None:
|
|
||||||
return error
|
|
||||||
elif not self._pending and self.timer is not None:
|
|
||||||
self._timer = self.recycle_async_timer(self._scheduler, self.timer, None)
|
|
||||||
|
|
||||||
def _execute(self, state: T, delay: Number):
|
|
||||||
errored = False
|
|
||||||
ex = None
|
|
||||||
try:
|
|
||||||
self._work(state)
|
|
||||||
except Exception as e:
|
|
||||||
errored = True
|
|
||||||
ex = e
|
|
||||||
|
|
||||||
if errored:
|
|
||||||
self.unsubscribe()
|
|
||||||
return ex
|
|
||||||
|
|
||||||
def unsubscribe(self):
|
|
||||||
if self.closed:
|
|
||||||
return
|
|
||||||
|
|
||||||
timer = self.timer
|
|
||||||
scheduler = self._scheduler
|
|
||||||
actions = self._scheduler.actions
|
|
||||||
|
|
||||||
self._work = None
|
|
||||||
self.state = None
|
|
||||||
self._scheduler = None
|
|
||||||
self._pending = False
|
|
||||||
self.delay = None
|
|
||||||
|
|
||||||
if self in actions:
|
|
||||||
actions.remove(self)
|
|
||||||
|
|
||||||
if self.timer is not None:
|
|
||||||
self.timer = self.recycle_async_timer(scheduler, timer, None)
|
|
||||||
|
|
||||||
Action.unsubscribe(self)
|
|
@ -1,55 +0,0 @@
|
|||||||
from typing import Callable
|
|
||||||
|
|
||||||
from cpl_core.type import T
|
|
||||||
from cpl_reactive_extensions.abc.observer import Observer
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
|
|
||||||
|
|
||||||
class OperatorSubscriber(Subscriber, Observer):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
destination: Subscriber,
|
|
||||||
on_next: Callable = None,
|
|
||||||
on_error: Callable = None,
|
|
||||||
on_complete: Callable = None,
|
|
||||||
on_finalize: Callable = None,
|
|
||||||
should_unsubscribe: Callable = None,
|
|
||||||
):
|
|
||||||
Subscriber.__init__(self, destination)
|
|
||||||
self._on_finalize = on_finalize
|
|
||||||
self._should_unsubscribe = should_unsubscribe
|
|
||||||
|
|
||||||
def on_next_wrapper(value: T):
|
|
||||||
try:
|
|
||||||
on_next(value)
|
|
||||||
except Exception as e:
|
|
||||||
destination.error(e)
|
|
||||||
|
|
||||||
self._on_next = on_next_wrapper if on_next is not None else self._on_next
|
|
||||||
|
|
||||||
def on_error_wrapper(value: T):
|
|
||||||
try:
|
|
||||||
on_error(value)
|
|
||||||
except Exception as e:
|
|
||||||
destination.error(e)
|
|
||||||
finally:
|
|
||||||
self.unsubscribe()
|
|
||||||
|
|
||||||
self._on_error = on_error_wrapper if on_error is not None else self._on_error
|
|
||||||
|
|
||||||
def on_complete_wrapper(value: T):
|
|
||||||
try:
|
|
||||||
on_complete(value)
|
|
||||||
except Exception as e:
|
|
||||||
destination.error(e)
|
|
||||||
finally:
|
|
||||||
self.unsubscribe()
|
|
||||||
|
|
||||||
self._on_complete = on_complete_wrapper if on_complete is not None else self._on_complete
|
|
||||||
|
|
||||||
def unsubscribe(self):
|
|
||||||
if self._should_unsubscribe is not None and not self._should_unsubscribe():
|
|
||||||
return
|
|
||||||
Subscriber.unsubscribe(self)
|
|
||||||
if not self.closed and self._on_finalize is not None:
|
|
||||||
self._on_finalize()
|
|
@ -1,65 +0,0 @@
|
|||||||
from typing import Callable
|
|
||||||
|
|
||||||
from cpl_core.type import T
|
|
||||||
from cpl_reactive_extensions.abc.observer import Observer
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
from cpl_reactive_extensions.type import ObserverOrCallable
|
|
||||||
|
|
||||||
|
|
||||||
class Subscriber(Subscription, Observer):
|
|
||||||
def __init__(
|
|
||||||
self, on_next_or_observer: ObserverOrCallable, on_error: Callable = None, on_complete: Callable = None
|
|
||||||
):
|
|
||||||
self.is_stopped = False
|
|
||||||
Subscription.__init__(self)
|
|
||||||
if isinstance(on_next_or_observer, Observer):
|
|
||||||
self._on_next = on_next_or_observer.next
|
|
||||||
self._on_error = on_next_or_observer.error
|
|
||||||
self._on_complete = on_next_or_observer.complete
|
|
||||||
else:
|
|
||||||
self._on_next = on_next_or_observer
|
|
||||||
self._on_error = on_error
|
|
||||||
self._on_complete = on_complete
|
|
||||||
|
|
||||||
def _next(self, value: T):
|
|
||||||
self._on_next(value)
|
|
||||||
|
|
||||||
def next(self, value: T):
|
|
||||||
if self.is_stopped:
|
|
||||||
raise Exception("Observer is closed")
|
|
||||||
|
|
||||||
self._next(value)
|
|
||||||
|
|
||||||
def _error(self, ex: Exception):
|
|
||||||
try:
|
|
||||||
self._on_error(ex)
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
self.unsubscribe()
|
|
||||||
|
|
||||||
def error(self, ex: Exception):
|
|
||||||
self._error(ex)
|
|
||||||
|
|
||||||
def _complete(self):
|
|
||||||
try:
|
|
||||||
self._on_complete()
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
self.unsubscribe()
|
|
||||||
|
|
||||||
def complete(self):
|
|
||||||
if self.is_stopped:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.is_stopped = True
|
|
||||||
self._complete()
|
|
||||||
|
|
||||||
def unsubscribe(self):
|
|
||||||
if self._closed:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.is_stopped = True
|
|
||||||
Subscription.unsubscribe(self)
|
|
||||||
self._on_next = None
|
|
@ -1,96 +0,0 @@
|
|||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import traceback
|
|
||||||
from typing import Union, Callable, Optional
|
|
||||||
|
|
||||||
from cpl_core.console import Console
|
|
||||||
from cpl_reactive_extensions.abc.unsubscribable import Unsubscribable
|
|
||||||
|
|
||||||
|
|
||||||
class Subscription(Unsubscribable):
|
|
||||||
@staticmethod
|
|
||||||
def empty():
|
|
||||||
empty = Subscription()
|
|
||||||
empty.closed = True
|
|
||||||
return empty
|
|
||||||
|
|
||||||
def __init__(self, initial_teardown: Optional[Callable] = None):
|
|
||||||
Unsubscribable.__init__(self)
|
|
||||||
|
|
||||||
self._initial_teardown = initial_teardown
|
|
||||||
|
|
||||||
self._closed = False
|
|
||||||
|
|
||||||
self._parentage: list[Subscription] = []
|
|
||||||
self._finalizers: list[Subscription] = []
|
|
||||||
|
|
||||||
@property
|
|
||||||
def closed(self) -> bool:
|
|
||||||
return self._closed
|
|
||||||
|
|
||||||
@closed.setter
|
|
||||||
def closed(self, value: bool):
|
|
||||||
self._closed = value
|
|
||||||
|
|
||||||
def _add_parent(self, parent: Subscription):
|
|
||||||
self._parentage.append(parent)
|
|
||||||
|
|
||||||
def _remove_parent(self, parent: Subscription):
|
|
||||||
if self == parent:
|
|
||||||
self._parentage.clear()
|
|
||||||
return
|
|
||||||
|
|
||||||
self._parentage.remove(parent)
|
|
||||||
|
|
||||||
def _has_parent(self, parent: Subscription) -> bool:
|
|
||||||
return parent in self._parentage
|
|
||||||
|
|
||||||
def _exec_finalizer(self, finalizer: Union[Callable, Unsubscribable]):
|
|
||||||
if isinstance(finalizer, Callable):
|
|
||||||
finalizer()
|
|
||||||
else:
|
|
||||||
finalizer.unsubscribe()
|
|
||||||
|
|
||||||
def unsubscribe(self):
|
|
||||||
if not self._closed:
|
|
||||||
self._closed = True
|
|
||||||
|
|
||||||
for parent in self._parentage:
|
|
||||||
parent.remove(self)
|
|
||||||
|
|
||||||
if self._initial_teardown is not None:
|
|
||||||
try:
|
|
||||||
self._initial_teardown()
|
|
||||||
except Exception as e:
|
|
||||||
Console.error(e, traceback.format_exc())
|
|
||||||
|
|
||||||
finalizers = self._finalizers
|
|
||||||
self._finalizers = None
|
|
||||||
for finalizer in finalizers:
|
|
||||||
try:
|
|
||||||
self._exec_finalizer(finalizer)
|
|
||||||
except Exception as e:
|
|
||||||
Console.error(e, traceback.format_exc())
|
|
||||||
|
|
||||||
def add(self, tear_down: Union[Subscription, Unsubscribable]):
|
|
||||||
if tear_down is None or tear_down == self:
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.closed:
|
|
||||||
self._exec_finalizer(tear_down)
|
|
||||||
return
|
|
||||||
|
|
||||||
if isinstance(tear_down, Subscription):
|
|
||||||
if tear_down.closed or tear_down._has_parent(self):
|
|
||||||
return
|
|
||||||
|
|
||||||
tear_down._add_parent(self)
|
|
||||||
|
|
||||||
self._finalizers.append(tear_down)
|
|
||||||
|
|
||||||
def remove(self, tear_down: Union[Subscription, Unsubscribable]):
|
|
||||||
if self._finalizers is not None:
|
|
||||||
self._finalizers.remove(tear_down)
|
|
||||||
|
|
||||||
if isinstance(tear_down, Subscription):
|
|
||||||
tear_down._remove_parent(self)
|
|
@ -1,10 +0,0 @@
|
|||||||
from typing import Callable
|
|
||||||
|
|
||||||
from cpl_core.type import Number
|
|
||||||
from cpl_reactive_extensions.timer import Timer
|
|
||||||
|
|
||||||
|
|
||||||
class TimerProvider:
|
|
||||||
@staticmethod
|
|
||||||
def set_timer(handler: Callable, timeout: Number = None, *args):
|
|
||||||
return Timer(timeout, handler, *args)
|
|
@ -1,20 +0,0 @@
|
|||||||
from typing import Callable
|
|
||||||
|
|
||||||
from cpl_reactive_extensions.observable import Observable
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
|
|
||||||
|
|
||||||
def operate(init: Callable[[Observable, Subscriber], None]):
|
|
||||||
def observable(source: Observable):
|
|
||||||
def create(self: Subscriber, lifted_source: Observable):
|
|
||||||
try:
|
|
||||||
return init(lifted_source, self)
|
|
||||||
except Exception as e:
|
|
||||||
self.error(e)
|
|
||||||
|
|
||||||
if "lift" not in dir(source):
|
|
||||||
raise TypeError("Unable to lift unknown Observable type")
|
|
||||||
|
|
||||||
return source.lift(create)
|
|
||||||
|
|
||||||
return observable
|
|
@ -1,47 +0,0 @@
|
|||||||
import sched
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
from typing import Callable
|
|
||||||
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
from cpl_reactive_extensions.observable import Observable
|
|
||||||
|
|
||||||
|
|
||||||
class Interval(Observable):
|
|
||||||
def __init__(self, interval: float, callback: Callable = None, not_in_background=False):
|
|
||||||
self._interval = interval
|
|
||||||
callback = callback if callback is not None else self._default_callback
|
|
||||||
|
|
||||||
def schedule(x: Subscriber):
|
|
||||||
scheduler = sched.scheduler(time.time, time.sleep)
|
|
||||||
scheduler.enter(
|
|
||||||
self._interval,
|
|
||||||
1,
|
|
||||||
self._run,
|
|
||||||
(scheduler, x, callback),
|
|
||||||
)
|
|
||||||
scheduler.run()
|
|
||||||
|
|
||||||
def thread(x: Subscriber):
|
|
||||||
t = threading.Thread(target=schedule, args=(x,))
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
Observable.__init__(self, schedule if not_in_background else thread)
|
|
||||||
self._i = 0
|
|
||||||
|
|
||||||
def _run(self, scheduler, x: Subscriber, callback: Callable):
|
|
||||||
if x.closed:
|
|
||||||
x.complete()
|
|
||||||
return
|
|
||||||
|
|
||||||
scheduler.enter(
|
|
||||||
self._interval,
|
|
||||||
1,
|
|
||||||
self._run,
|
|
||||||
(scheduler, x, callback),
|
|
||||||
)
|
|
||||||
callback(x)
|
|
||||||
|
|
||||||
def _default_callback(self, x: Subscriber):
|
|
||||||
x.next(self._i)
|
|
||||||
self._i += 1
|
|
@ -1,114 +0,0 @@
|
|||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import Callable, Any, Optional
|
|
||||||
|
|
||||||
from cpl_core.type import T
|
|
||||||
from cpl_reactive_extensions.abc.observer import Observer
|
|
||||||
from cpl_reactive_extensions.abc.subscribable import Subscribable
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
from cpl_reactive_extensions.type import ObserverOrCallable
|
|
||||||
|
|
||||||
|
|
||||||
class Observable(Subscribable):
|
|
||||||
def __init__(self, subscribe: Callable = None):
|
|
||||||
Subscribable.__init__(self)
|
|
||||||
if subscribe is not None:
|
|
||||||
self._subscribe = subscribe
|
|
||||||
|
|
||||||
self._source: Optional[Observable] = None
|
|
||||||
self._operator: Optional[Callable] = None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_observable(obs: Observable):
|
|
||||||
def inner(subscriber: Subscriber):
|
|
||||||
if "subscribe" not in dir(obs):
|
|
||||||
raise TypeError("Unable to lift unknown Observable type")
|
|
||||||
|
|
||||||
return obs.subscribe(subscriber)
|
|
||||||
|
|
||||||
return Observable(inner)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_list(values: list):
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
def callback(x: Subscriber):
|
|
||||||
nonlocal i
|
|
||||||
if i == len(values):
|
|
||||||
i = 0
|
|
||||||
x.complete()
|
|
||||||
else:
|
|
||||||
x.next(values[i])
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
if not x.closed:
|
|
||||||
callback(x)
|
|
||||||
|
|
||||||
observable = Observable(callback)
|
|
||||||
return observable
|
|
||||||
|
|
||||||
def lift(self, operator: Callable) -> Observable:
|
|
||||||
observable = Observable()
|
|
||||||
observable._source = self
|
|
||||||
observable._operator = operator
|
|
||||||
return observable
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _is_observer(value: Any) -> bool:
|
|
||||||
return isinstance(value, Observer)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _is_subscription(value: Any) -> bool:
|
|
||||||
return isinstance(value, Subscription)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _is_subscriber(value: Any) -> bool:
|
|
||||||
return isinstance(value, Subscriber) or Observable._is_observer(value) and Observable._is_subscription(value)
|
|
||||||
|
|
||||||
def _subscribe(self, subscriber: Subscriber) -> Subscription:
|
|
||||||
return self._source.subscribe(subscriber)
|
|
||||||
|
|
||||||
def _try_subscribe(self, subscriber: Subscriber) -> Subscription:
|
|
||||||
try:
|
|
||||||
return self._subscribe(subscriber)
|
|
||||||
except Exception as e:
|
|
||||||
subscriber.error(e)
|
|
||||||
|
|
||||||
def subscribe(
|
|
||||||
self, observer_or_next: ObserverOrCallable, on_error: Callable = None, on_complete: Callable = None
|
|
||||||
) -> Subscription:
|
|
||||||
subscriber = (
|
|
||||||
observer_or_next
|
|
||||||
if Observable._is_subscriber(observer_or_next)
|
|
||||||
else Subscriber(observer_or_next, on_error, on_complete)
|
|
||||||
)
|
|
||||||
|
|
||||||
subscriber.add(
|
|
||||||
self._operator(subscriber, self._source)
|
|
||||||
if self._operator is not None
|
|
||||||
else self._subscribe(subscriber)
|
|
||||||
if self._source is not None
|
|
||||||
else self._try_subscribe(subscriber)
|
|
||||||
)
|
|
||||||
|
|
||||||
return subscriber
|
|
||||||
|
|
||||||
def pipe(self, *args) -> Observable:
|
|
||||||
return self._pipe_from_array(args)(self)
|
|
||||||
|
|
||||||
def _pipe_from_array(self, args):
|
|
||||||
if len(args) == 0:
|
|
||||||
return lambda x: x
|
|
||||||
|
|
||||||
if len(args) == 1:
|
|
||||||
return args[0]
|
|
||||||
|
|
||||||
def piped(input: T):
|
|
||||||
return Observable._reduce(lambda prev, fn: fn(prev), input)
|
|
||||||
|
|
||||||
return piped
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _reduce(func: Callable, input: T):
|
|
||||||
return func(input)
|
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
cpl-reactive-extensions CPL Simple ReactiveX implementation
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
CPL Simple ReactiveX implementation, see RxJS and RxPy for detailed implementation.
|
|
||||||
|
|
||||||
:copyright: (c) 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "cpl_reactive_extensions.operators"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2023 sh-edraft.de"
|
|
||||||
__version__ = "2023.4.dev170"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports:
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
|
@ -1,62 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from cpl_core.type import T, Number
|
|
||||||
from cpl_reactive_extensions.abc.scheduler_action import SchedulerAction
|
|
||||||
from cpl_reactive_extensions.internal.operator_subscriber import OperatorSubscriber
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
from cpl_reactive_extensions.internal.subscription import Subscription
|
|
||||||
from cpl_reactive_extensions.internal.utils import operate
|
|
||||||
from cpl_reactive_extensions.observable import Observable
|
|
||||||
from cpl_reactive_extensions.scheduler.async_scheduler import async_scheduler
|
|
||||||
|
|
||||||
|
|
||||||
def debounce_time(time: Number, scheduler=async_scheduler):
|
|
||||||
def init(source: Observable, subscriber: Subscriber):
|
|
||||||
active_task: Optional[Subscription] = None
|
|
||||||
last_value: Optional[T] = None
|
|
||||||
last_time: Optional[Number] = None
|
|
||||||
|
|
||||||
def emit():
|
|
||||||
nonlocal active_task, last_value
|
|
||||||
|
|
||||||
if active_task is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
active_task.unsubscribe()
|
|
||||||
active_task = None
|
|
||||||
value = last_value
|
|
||||||
last_value = None
|
|
||||||
subscriber.next(value)
|
|
||||||
|
|
||||||
def emit_when_idle(action: SchedulerAction):
|
|
||||||
nonlocal active_task, last_time
|
|
||||||
target_time = last_time + time
|
|
||||||
now = scheduler.now
|
|
||||||
|
|
||||||
if now < target_time:
|
|
||||||
active_task = action.schedule(None, target_time - now)
|
|
||||||
subscriber.add(active_task)
|
|
||||||
return
|
|
||||||
|
|
||||||
emit()
|
|
||||||
|
|
||||||
def on_next(value: T):
|
|
||||||
nonlocal active_task, last_value
|
|
||||||
last_value = value
|
|
||||||
|
|
||||||
if active_task is None:
|
|
||||||
active_task = scheduler.schedule(emit_when_idle, time)
|
|
||||||
subscriber.add(active_task)
|
|
||||||
|
|
||||||
def on_complete():
|
|
||||||
emit()
|
|
||||||
subscriber.complete()
|
|
||||||
|
|
||||||
def on_finalize():
|
|
||||||
nonlocal active_task, last_value
|
|
||||||
last_value = None
|
|
||||||
active_task = None
|
|
||||||
|
|
||||||
sub = source.subscribe(OperatorSubscriber(subscriber, on_next, None, on_complete, on_finalize))
|
|
||||||
|
|
||||||
return operate(init)
|
|
@ -1,29 +0,0 @@
|
|||||||
from cpl_core.type import T
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
from cpl_reactive_extensions.observable import Observable
|
|
||||||
from cpl_reactive_extensions.internal.operator_subscriber import OperatorSubscriber
|
|
||||||
from cpl_reactive_extensions.internal.utils import operate
|
|
||||||
|
|
||||||
|
|
||||||
def take(count: int):
|
|
||||||
if count <= 0:
|
|
||||||
return Observable()
|
|
||||||
|
|
||||||
def init(source: Observable, subscriber: Subscriber):
|
|
||||||
seen = 0
|
|
||||||
|
|
||||||
def on_next(value: T):
|
|
||||||
nonlocal seen
|
|
||||||
|
|
||||||
if seen + 1 <= count:
|
|
||||||
seen += 1
|
|
||||||
subscriber.next(value)
|
|
||||||
|
|
||||||
if count <= seen:
|
|
||||||
subscriber.complete()
|
|
||||||
else:
|
|
||||||
sub.unsubscribe()
|
|
||||||
|
|
||||||
sub = source.subscribe(OperatorSubscriber(subscriber, on_next))
|
|
||||||
|
|
||||||
return operate(init)
|
|
@ -1,14 +0,0 @@
|
|||||||
from cpl_reactive_extensions.observable import Observable
|
|
||||||
from cpl_reactive_extensions.internal.operator_subscriber import OperatorSubscriber
|
|
||||||
from cpl_reactive_extensions.internal.subscriber import Subscriber
|
|
||||||
from cpl_reactive_extensions.internal.utils import operate
|
|
||||||
|
|
||||||
|
|
||||||
def take_until(notifier: Observable):
|
|
||||||
def init(source: Observable, subscriber: Subscriber):
|
|
||||||
Observable.from_observable(notifier).subscribe(OperatorSubscriber(subscriber, lambda: subscriber.complete()))
|
|
||||||
|
|
||||||
if not subscriber.closed:
|
|
||||||
source.subscribe(subscriber)
|
|
||||||
|
|
||||||
return operate(init)
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user