* Bump pylint from 2.13.5 to 3.1.0 Bumps [pylint](https://github.com/pylint-dev/pylint) from 2.13.5 to 3.1.0. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v2.13.5...v3.1.0) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * bend knee to pylint --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jesse Bannon <jbann1994@gmail.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from typing import List
|
|
from typing import Optional
|
|
from typing import Tuple
|
|
from typing import Type
|
|
|
|
from ytdl_sub.config.plugin.plugin import Plugin
|
|
from ytdl_sub.config.validators.options import OptionsValidator
|
|
from ytdl_sub.config.validators.options import OptionsValidatorT
|
|
|
|
|
|
class PresetPlugins:
|
|
def __init__(self):
|
|
self.plugin_types: List[Type[Plugin]] = []
|
|
self.plugin_options: List[OptionsValidator] = []
|
|
|
|
def add(self, plugin_type: Type[Plugin], plugin_options: OptionsValidator) -> "PresetPlugins":
|
|
"""
|
|
Add a pair of plugin type and options to the list
|
|
"""
|
|
self.plugin_types.append(plugin_type)
|
|
self.plugin_options.append(plugin_options)
|
|
return self
|
|
|
|
def zipped(self) -> List[Tuple[Type[Plugin], OptionsValidator]]:
|
|
"""
|
|
Returns
|
|
-------
|
|
Plugin and PluginOptions zipped
|
|
"""
|
|
return list(zip(self.plugin_types, self.plugin_options))
|
|
|
|
def get(self, plugin_type: Type[OptionsValidatorT]) -> Optional[OptionsValidatorT]:
|
|
"""
|
|
Parameters
|
|
----------
|
|
plugin_type
|
|
Fetch the plugin options for this type
|
|
|
|
Returns
|
|
-------
|
|
Options of this plugin if they exit. Otherwise, return None.
|
|
"""
|
|
plugin_option_types = [type(plugin_options) for plugin_options in self.plugin_options]
|
|
if plugin_type in plugin_option_types:
|
|
return self.plugin_options[plugin_option_types.index(plugin_type)]
|
|
return None
|