plugins: Move plugins to dedicated submodule
This change groups the plugin modules together under kas.plugins and moves the @kasplugin decorator to this submodule. This will ensure the codebase stays organised as more plugins are added. Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
af4389e606
commit
1dffb986b1
@ -47,9 +47,9 @@ from . import __version__, __file_version__, __compatible_file_version__
|
||||
# Import kas plugins
|
||||
# Since they are added by decorators, they don't need to be called,
|
||||
# just imported.
|
||||
from .libkas import kasplugin
|
||||
from . import build
|
||||
from . import shell
|
||||
from .plugins import kasplugin
|
||||
from .plugins import build
|
||||
from .plugins import shell
|
||||
|
||||
__all__ = ['build', 'shell']
|
||||
|
||||
|
@ -327,14 +327,3 @@ def ssh_no_host_key_check():
|
||||
os.mkdir(home + '/.ssh')
|
||||
with open(home + '/.ssh/config', 'w') as fds:
|
||||
fds.write('Host *\n\tStrictHostKeyChecking no\n\n')
|
||||
|
||||
|
||||
def kasplugin(plugin_class):
|
||||
"""
|
||||
A decorator that registers kas plugins
|
||||
"""
|
||||
if not hasattr(kasplugin, 'plugins'):
|
||||
setattr(kasplugin, 'plugins', {})
|
||||
getattr(kasplugin, 'plugins').update({
|
||||
plugin_class.name: plugin_class
|
||||
})
|
||||
|
35
kas/plugins/__init__.py
Normal file
35
kas/plugins/__init__.py
Normal file
@ -0,0 +1,35 @@
|
||||
# kas - setup tool for bitbake based projects
|
||||
#
|
||||
# Copyright (c) Siemens AG, 2017-2018
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
"""
|
||||
This module contains and manages kas plugins
|
||||
"""
|
||||
|
||||
|
||||
def kasplugin(plugin_class):
|
||||
"""
|
||||
A decorator that registers kas plugins
|
||||
"""
|
||||
if not hasattr(kasplugin, 'plugins'):
|
||||
setattr(kasplugin, 'plugins', {})
|
||||
getattr(kasplugin, 'plugins').update({
|
||||
plugin_class.name: plugin_class
|
||||
})
|
@ -27,14 +27,15 @@ import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from .context import create_global_context
|
||||
from .config import Config
|
||||
from .libkas import find_program, run_cmd, kasplugin
|
||||
from .libcmds import (Macro, Command, SetupDir, CleanupSSHAgent,
|
||||
SetupSSHAgent, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libkas import find_program, run_cmd
|
||||
from kas.libcmds import (Macro, Command, SetupDir, CleanupSSHAgent,
|
||||
SetupSSHAgent, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.plugins import kasplugin
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
@ -28,14 +28,14 @@ import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from .libkas import kasplugin
|
||||
from .context import create_global_context
|
||||
from .config import Config
|
||||
from .libcmds import (Macro, Command, SetupDir, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
CleanupSSHAgent, SetupSSHAgent,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libcmds import (Macro, Command, SetupDir, SetupEnviron,
|
||||
WriteBBConfig, SetupHome, ReposApplyPatches,
|
||||
CleanupSSHAgent, SetupSSHAgent,
|
||||
Loop, InitSetupRepos, FinishSetupRepos,
|
||||
SetupReposStep)
|
||||
from kas.plugins import kasplugin
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
Loading…
Reference in New Issue
Block a user