forked from meltano/meltano
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Register legacy
DiscoveryFile
object in Ruamel YAML instance (m…
…eltano#6543) * fix yaml calls to old lib impl * Register DiscoveryFile globally * Make linter happy Co-authored-by: Edgar R. M <edgarrm358@gmail.com>
- Loading branch information
1 parent
8e8e4a9
commit d14ff93
Showing
5 changed files
with
84 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Legacy discovery file object.""" | ||
|
||
from __future__ import annotations | ||
|
||
from .behavior.canonical import Canonical | ||
from .plugin import PluginDefinition, PluginType | ||
|
||
|
||
class DiscoveryFile(Canonical): | ||
"""A discovery file object.""" | ||
|
||
def __init__(self, version=1, **plugins): | ||
"""Create a new DiscoveryFile. | ||
Args: | ||
version: The version of the discovery file. | ||
plugins: The plugins to add to the discovery file. | ||
""" | ||
super().__init__(version=int(version)) | ||
|
||
for ptype in PluginType: | ||
self[ptype] = [] | ||
|
||
for plugin_type, raw_plugins in plugins.items(): | ||
for raw_plugin in raw_plugins: | ||
plugin_def = PluginDefinition( | ||
plugin_type, | ||
raw_plugin.pop("name"), | ||
raw_plugin.pop("namespace"), | ||
**raw_plugin, | ||
) | ||
self[plugin_type].append(plugin_def) | ||
|
||
@classmethod | ||
def file_version(cls, attrs): | ||
"""Return version of discovery file represented by attrs dictionary. | ||
Args: | ||
attrs: The attributes of the discovery file. | ||
Returns: | ||
The version of the discovery file. | ||
""" | ||
return int(attrs.get("version", 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters