From 639a7bd51ba60112b32a3991a36f69b13a9a4157 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 27 Sep 2022 14:35:54 -0700 Subject: [PATCH] 8927 cleanup - optimize --- netbox/circuits/search_indexes.py | 6 +++--- netbox/dcim/search_indexes.py | 22 +++++++++++----------- netbox/extras/search_indexes.py | 2 +- netbox/ipam/search_indexes.py | 14 +++++++------- netbox/search/apps.py | 9 --------- netbox/tenancy/search_indexes.py | 4 ++-- netbox/virtualization/search_indexes.py | 4 ++-- netbox/wireless/search_indexes.py | 4 ++-- 8 files changed, 28 insertions(+), 37 deletions(-) diff --git a/netbox/circuits/search_indexes.py b/netbox/circuits/search_indexes.py index 76f4d4f12..e0d793363 100644 --- a/netbox/circuits/search_indexes.py +++ b/netbox/circuits/search_indexes.py @@ -36,7 +36,7 @@ class ProviderNetworkIndex(SearchMixin): CIRCUIT_SEARCH_TYPES = { - 'provider': ProviderIndex(), - 'circuit': CircuitIndex(), - 'providernetwork': ProviderNetworkIndex(), + 'provider': ProviderIndex, + 'circuit': CircuitIndex, + 'providernetwork': ProviderNetworkIndex, } diff --git a/netbox/dcim/search_indexes.py b/netbox/dcim/search_indexes.py index 65019c3d0..07cb51798 100644 --- a/netbox/dcim/search_indexes.py +++ b/netbox/dcim/search_indexes.py @@ -146,15 +146,15 @@ class PowerFeedIndex(SearchMixin): DCIM_SEARCH_TYPES = { - 'site': SiteIndex(), - 'rack': RackIndex(), - 'rackreservation': RackReservationIndex(), - 'location': LocationIndex(), - 'devicetype': DeviceTypeIndex(), - 'device': DeviceIndex(), - 'moduletype': ModuleTypeIndex(), - 'module': ModuleIndex(), - 'virtualchassis': VirtualChassisIndex(), - 'cable': CableIndex(), - 'powerfeed': PowerFeedIndex(), + 'site': SiteIndex, + 'rack': RackIndex, + 'rackreservation': RackReservationIndex, + 'location': LocationIndex, + 'devicetype': DeviceTypeIndex, + 'device': DeviceIndex, + 'moduletype': ModuleTypeIndex, + 'module': ModuleIndex, + 'virtualchassis': VirtualChassisIndex, + 'cable': CableIndex, + 'powerfeed': PowerFeedIndex, } diff --git a/netbox/extras/search_indexes.py b/netbox/extras/search_indexes.py index 7b5014cfe..ab6a8394f 100644 --- a/netbox/extras/search_indexes.py +++ b/netbox/extras/search_indexes.py @@ -16,5 +16,5 @@ class JournalEntryIndex(SearchMixin): JOURNAL_SEARCH_TYPES = { - 'journalentry': JournalEntryIndex(), + 'journalentry': JournalEntryIndex, } diff --git a/netbox/ipam/search_indexes.py b/netbox/ipam/search_indexes.py index 32e14292b..5d7358c8f 100644 --- a/netbox/ipam/search_indexes.py +++ b/netbox/ipam/search_indexes.py @@ -72,11 +72,11 @@ class ServiceIndex(SearchMixin): IPAM_SEARCH_TYPES = { - 'vrf': VRFIndex(), - 'aggregate': AggregateIndex(), - 'prefix': PrefixIndex(), - 'ipaddress': IPAddressIndex(), - 'vlan': VLANIndex(), - 'asn': ASNIndex(), - 'service': ServiceIndex(), + 'vrf': VRFIndex, + 'aggregate': AggregateIndex, + 'prefix': PrefixIndex, + 'ipaddress': IPAddressIndex, + 'vlan': VLANIndex, + 'asn': ASNIndex, + 'service': ServiceIndex, } diff --git a/netbox/search/apps.py b/netbox/search/apps.py index 4d47d8a52..363dfe1bf 100644 --- a/netbox/search/apps.py +++ b/netbox/search/apps.py @@ -15,15 +15,6 @@ def get_app_modules(): yield app.name, app.module -def get_app_submodules(submodule_name): - """ - Searches each app module for the specified submodule - yields tuples of (app_name, module) - """ - for name, module in get_app_modules(): - if module_has_submodule(module, submodule_name): - yield name, import_module(f"{name}.{submodule_name}") - - class SearchConfig(AppConfig): name = "search" verbose_name = "search" diff --git a/netbox/tenancy/search_indexes.py b/netbox/tenancy/search_indexes.py index c6ddc38fa..e7d84abc9 100644 --- a/netbox/tenancy/search_indexes.py +++ b/netbox/tenancy/search_indexes.py @@ -27,6 +27,6 @@ class ContactIndex(SearchMixin): TENANCY_SEARCH_TYPES = { - 'tenant': TenantIndex(), - 'contact': ContactIndex(), + 'tenant': TenantIndex, + 'contact': ContactIndex, } diff --git a/netbox/virtualization/search_indexes.py b/netbox/virtualization/search_indexes.py index 2bb2d57d7..8b7879062 100644 --- a/netbox/virtualization/search_indexes.py +++ b/netbox/virtualization/search_indexes.py @@ -34,6 +34,6 @@ class VirtualMachineIndex(SearchMixin): VIRTUALIZATION_SEARCH_TYPES = { - 'cluster': ClusterIndex(), - 'virtualmachine': VirtualMachineIndex(), + 'cluster': ClusterIndex, + 'virtualmachine': VirtualMachineIndex, } diff --git a/netbox/wireless/search_indexes.py b/netbox/wireless/search_indexes.py index 1878ef753..cb37aff64 100644 --- a/netbox/wireless/search_indexes.py +++ b/netbox/wireless/search_indexes.py @@ -28,6 +28,6 @@ class WirelessLinkIndex(SearchMixin): WIRELESS_SEARCH_TYPES = { - 'wirelesslan': WirelessLANIndex(), - 'wirelesslink': WirelessLinkIndex(), + 'wirelesslan': WirelessLANIndex, + 'wirelesslink': WirelessLinkIndex, }