(url)
| 104 | |
| 105 | |
| 106 | def _get_plugin(url): # type: (str) -> SecureStorageBase |
| 107 | if not url: |
| 108 | raise SecureStorageException(f'Configuration file error: "{CONFIG_STORAGE_URL}" cannot be empty') |
| 109 | par = urlparse(url) |
| 110 | if not par.scheme: |
| 111 | raise SecureStorageException(f'Configuration file error: "{CONFIG_STORAGE_URL}" is not URL') |
| 112 | |
| 113 | plugin_name = par.scheme.replace('-', '_') |
| 114 | if not any(x for x in pkgutil.iter_modules(config_storage.__path__) if x.name == plugin_name): |
| 115 | raise SecureStorageException(f'Protected storage "{plugin_name}" is not supported') |
| 116 | |
| 117 | module_name = f'keepercommander.config_storage.{plugin_name}' |
| 118 | try: |
| 119 | logging.debug('Importing config storage module "%s"', module_name) |
| 120 | module = importlib.import_module(module_name) |
| 121 | except ModuleNotFoundError as me: |
| 122 | dependency_not_installed = f'{plugin_name} requires {me.name} package to be installed\n' \ |
| 123 | f'pip install {me.name}' |
| 124 | raise SecureStorageException(dependency_not_installed) |
| 125 | if not hasattr(module, 'SecureStorage'): |
| 126 | raise SecureStorageException(f'Protected storage "{plugin_name}" is invalid') |
| 127 | storage_class = getattr(module, 'SecureStorage') |
| 128 | storage = storage_class() # type: SecureStorageBase |
| 129 | if not isinstance(storage, SecureStorageBase): |
| 130 | raise SecureStorageException(f'Protected storage "{plugin_name}" is invalid') |
| 131 | return storage |
| 132 | |
| 133 | |
| 134 | def split_name(name): # type: (Union[str, Tuple[str, str]]) -> Tuple[str, str] |
no test coverage detected