/
usr
/
lib
/
python3
/
dist-packages
/
cloudinit
/
/usr/lib/python3/dist-packages/cloudinit
mkdir
upload
Name
Size
Mode
Actions
analyze/
-
0755
rm
cmd/
-
0755
rm
config/
-
0755
rm
distros/
-
0755
rm
filters/
-
0755
rm
handlers/
-
0755
rm
log/
-
0755
rm
mergers/
-
0755
rm
net/
-
0755
rm
reporting/
-
0755
rm
sources/
-
0755
rm
__pycache__/
-
0755
rm
apport.py
8496
0644
edit
dl
rm
atomic_helper.py
2860
0644
edit
dl
rm
cloud.py
3296
0644
edit
dl
rm
dmi.py
8002
0644
edit
dl
rm
event.py
2051
0644
edit
dl
rm
features.py
5763
0644
edit
dl
rm
gpg.py
8186
0644
edit
dl
rm
helpers.py
16547
0644
edit
dl
rm
importer.py
2485
0644
edit
dl
rm
lifecycle.py
7979
0644
edit
dl
rm
netinfo.py
24646
0644
edit
dl
rm
performance.py
3175
0644
edit
dl
rm
persistence.py
2583
0644
edit
dl
rm
registry.py
1022
0644
edit
dl
rm
safeyaml.py
10349
0644
edit
dl
rm
settings.py
2172
0644
edit
dl
rm
signal_handler.py
3027
0644
edit
dl
rm
simpletable.py
1976
0644
edit
dl
rm
socket.py
5991
0644
edit
dl
rm
ssh_util.py
22983
0644
edit
dl
rm
stages.py
42526
0644
edit
dl
rm
subp.py
12658
0644
edit
dl
rm
templater.py
7930
0644
edit
dl
rm
temp_utils.py
3013
0644
edit
dl
rm
type_utils.py
703
0644
edit
dl
rm
url_helper.py
39164
0644
edit
dl
rm
user_data.py
14784
0644
edit
dl
rm
util.py
92907
0644
edit
dl
rm
version.py
564
0644
edit
dl
rm
warnings.py
3853
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/usr/lib/python3/dist-packages/cloudinit/importer.py
(2485B)
# Copyright (C) 2012 Canonical Ltd. # Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # Copyright (C) 2012 Yahoo! Inc. # # Author: Scott Moser <scott.moser@canonical.com> # Author: Juerg Haefliger <juerg.haefliger@hp.com> # Author: Joshua Harlow <harlowja@yahoo-inc.com> # # This file is part of cloud-init. See LICENSE file for license information. import importlib from types import ModuleType from typing import Optional, Sequence from cloudinit import util def import_module(module_name: str) -> ModuleType: return importlib.import_module(module_name) def _count_attrs( module_name: str, attrs: Optional[Sequence[str]] = None ) -> int: found_attrs = 0 if not attrs: return found_attrs mod = importlib.import_module(module_name) for attr in attrs: if hasattr(mod, attr): found_attrs += 1 return found_attrs def match_case_insensitive_module_name(mod_name: str) -> Optional[str]: """Check the importable datasource modules for a case-insensitive match.""" # nocloud-net is the only datasource that requires matching on a name that # does not match its python module - canonicalize it here if "nocloud-net" == mod_name.lower(): mod_name = mod_name[:-4] if not mod_name.startswith("DataSource"): mod_name = f"DataSource{mod_name}" modules = {} spec = importlib.util.find_spec("cloudinit.sources") if spec and spec.submodule_search_locations: for dir in spec.submodule_search_locations: modules.update(util.get_modules_from_dir(dir)) for module in modules.values(): if module.lower() == mod_name.lower(): return module return mod_name def find_module( base_name: str, search_paths: Sequence[str], required_attrs: Optional[Sequence[str]] = None, ) -> tuple: """Finds specified modules""" if not required_attrs: required_attrs = [] lookup_paths = [] found_paths = [] for path in search_paths: # Add base name to search paths. Filter out empty paths. full_path = ".".join(filter(None, [path, base_name])) lookup_paths.append(full_path) if not importlib.util.find_spec(full_path): continue # Check that required_attrs are all present within the module. if _count_attrs(full_path, required_attrs) == len(required_attrs): found_paths.append(full_path) return (found_paths, lookup_paths)
Save
cmd:
run