msticpy/sectools/tilookup.py
def _load_providers(self):
        """Load provider classes based on config."""
        prov_settings = get_provider_settings()

        for provider_entry, settings in prov_settings.items():
            # Allow overriding provider name to use another class
            provider_name = settings.provider or provider_entry
            if self._providers_to_load and provider_name not in self._providers_to_load:
                continue
            provider_class: TIProvider = getattr(
                sys.modules[__name__], provider_name, None
            )
            if not provider_class:
                warnings.warn(
                    f"Could not find provider class for {provider_name} "
                    f"in config section {provider_entry}"
                )
                continue

            # instantiate class sending args from settings to init
            try:
                provider_instance = provider_class(**(settings.args))
            except MsticpyConfigException as mp_ex:
                # If the TI Provider didn't load, raise an exception
                raise MsticpyUserConfigError(
                    f"Could not load TI Provider {provider_name}",
                    *mp_ex.args,
                    "To avoid loading this provider please use the 'providers' parameter"
                    + " to TILookup() to specify which providers to load.",
                    title="TIProvider configuration error",
                    help_uri=(
                        "https://msticpy.readthedocs.io/en/latest/data_acquisition/TIProviders.html"
                        + "#configuration-file"
                    ),
                ) from mp_ex

            # set the description from settings, if one is provided, otherwise
            # use class docstring.
            provider_instance.description = (
                settings.description or provider_instance.__doc__
            )

            self.add_provider(
                provider=provider_instance, name=provider_name, primary=settings.primary
            )
Load provider classes based on config.
Load provider classes based on config.
Load provider classes based on config .
def _load_providers(self):
        prov_settings = get_provider_settings()
        for provider_entry, settings in prov_settings.items():
            provider_name = settings.provider or provider_entry
            if self._providers_to_load and provider_name not in self._providers_to_load:
                continue
            provider_class: TIProvider = getattr(
                sys.modules[__name__], provider_name, None
            )
            if not provider_class:
                warnings.warn(
                    f"Could not find provider class for {provider_name} "
                    f"in config section {provider_entry}"
                )
                continue
            try:
                provider_instance = provider_class(**(settings.args))
            except MsticpyConfigException as mp_ex:
                raise MsticpyUserConfigError(
                    f"Could not load TI Provider {provider_name}",
                    *mp_ex.args,
                    "To avoid loading this provider please use the 'providers' parameter"
                    + " to TILookup() to specify which providers to load.",
                    title="TIProvider configuration error",
                    help_uri=(
                        "https://msticpy.readthedocs.io/en/latest/data_acquisition/TIProviders.html"
                        + "#configuration-file"
                    ),
                ) from mp_ex
            provider_instance.description = (
                settings.description or provider_instance.__doc__
            )
            self.add_provider(
                provider=provider_instance, name=provider_name, primary=settings.primary
            )
def _load_providers ( self ) : prov_settings = get_provider_settings ( ) for provider_entry , settings in prov_settings . items ( ) : provider_name = settings . provider or provider_entry if self . _providers_to_load and provider_name not in self . _providers_to_load : continue provider_class : TIProvider = getattr ( sys . modules [ __name__ ] , provider_name , None ) if not provider_class : warnings . warn ( f"Could not find provider class for {provider_name} " f"in config section {provider_entry}" ) continue try : provider_instance = provider_class ( ** ( settings . args ) ) except MsticpyConfigException as mp_ex : raise MsticpyUserConfigError ( f"Could not load TI Provider {provider_name}" , * mp_ex . args , "To avoid loading this provider please use the 'providers' parameter" + " to TILookup() to specify which providers to load." , title = "TIProvider configuration error" , help_uri = ( "https://msticpy.readthedocs.io/en/latest/data_acquisition/TIProviders.html" + "#configuration-file" ) , ) from mp_ex provider_instance . description = ( settings . description or provider_instance . __doc__ ) self . add_provider ( provider = provider_instance , name = provider_name , primary = settings . primary )
Load provider classes based on config.
Load provider classes based on config .
"""Load provider classes based on config.""" # Allow overriding provider name to use another class # instantiate class sending args from settings to init # If the TI Provider didn't load, raise an exception # set the description from settings, if one is provided, otherwise # use class docstring.
self