diff options
| author | zdc <zdc@users.noreply.github.com> | 2022-04-07 20:24:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-07 20:24:57 +0300 |
| commit | 45c1d42e15f4a5fe5e176e1516b2da9d21e7837a (patch) | |
| tree | 0535c3cf76b60dbf585416b4490c5bd9c9c99359 /cloudinit/importer.py | |
| parent | 96226f37cdbdaef2fbc51de7b9ca75b61a16792b (diff) | |
| parent | aa60d48c2711cdcd9f88a4e5c77379adb0408231 (diff) | |
| download | vyos-cloud-init-45c1d42e15f4a5fe5e176e1516b2da9d21e7837a.tar.gz vyos-cloud-init-45c1d42e15f4a5fe5e176e1516b2da9d21e7837a.zip | |
Merge pull request #52 from vyos/current
T2117: Backport Cloud-init 22.1 with our changes to VyOS 1.3
Diffstat (limited to 'cloudinit/importer.py')
| -rw-r--r-- | cloudinit/importer.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/cloudinit/importer.py b/cloudinit/importer.py index f1194fbe..2bc210dd 100644 --- a/cloudinit/importer.py +++ b/cloudinit/importer.py @@ -9,6 +9,25 @@ # This file is part of cloud-init. See LICENSE file for license information. import sys +import typing + +# annotations add value for development, but don't break old versions +# pyver: 3.6 -> 3.8 +# pylint: disable=E1101 +if sys.version_info >= (3, 8): + + class MetaSchema(typing.TypedDict): + name: str + id: str + title: str + description: str + distros: typing.List[str] + examples: typing.List[str] + frequency: str + +else: + MetaSchema = dict +# pylint: enable=E1101 def import_module(module_name): @@ -16,7 +35,8 @@ def import_module(module_name): return sys.modules[module_name] -def find_module(base_name, search_paths, required_attrs=None): +def find_module(base_name: str, search_paths, required_attrs=None) -> tuple: + """Finds and imports specified modules""" if not required_attrs: required_attrs = [] # NOTE(harlowja): translate the search paths to include the base name. @@ -26,7 +46,7 @@ def find_module(base_name, search_paths, required_attrs=None): if path: real_path.extend(path.split(".")) real_path.append(base_name) - full_path = '.'.join(real_path) + full_path = ".".join(real_path) lookup_paths.append(full_path) found_paths = [] for full_path in lookup_paths: @@ -45,4 +65,5 @@ def find_module(base_name, search_paths, required_attrs=None): found_paths.append(full_path) return (found_paths, lookup_paths) + # vi: ts=4 expandtab |
