Fixes: 1) Remove unused imports in `vendors.py`, `tasks.py`, and `emailing.py`. Extra: 1) Minor cleanup of redundant functions and variables in `vendors.py`; 2) Reorganize imports for clarity and consistency.
25 lines
832 B
Python
25 lines
832 B
Python
import logging
|
|
from typing import Type
|
|
|
|
from core.models import Vendor
|
|
from core.vendors import AbstractVendor
|
|
from evibes.utils.misc import create_object
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def get_vendors_integrations(name: str | None = None) -> list[Type[AbstractVendor]]:
|
|
vendors_integrations: list[Type[AbstractVendor]] = []
|
|
|
|
vendors = Vendor.objects.filter(is_active=True, integration_path__isnull=False)
|
|
if name:
|
|
vendors = vendors.filter(name=name)
|
|
|
|
for vendor in vendors:
|
|
try:
|
|
module_name, class_name = vendor.integration_path.rsplit(".", 1)
|
|
vendors_integrations.append(create_object(module_name, class_name))
|
|
except Exception as e:
|
|
logger.warning("Couldn't load integration for vendor %s: %s", vendor.name, e)
|
|
|
|
return vendors_integrations
|