1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #9896: Discontinue arbitrary use of OrderedDict

This commit is contained in:
jeremystretch
2022-08-01 16:51:44 -04:00
parent 562769fb89
commit 29a611c729
9 changed files with 65 additions and 78 deletions

View File

@@ -3,7 +3,6 @@ import inspect
import logging
import pkgutil
import traceback
from collections import OrderedDict
from django.conf import settings
from django.utils import timezone
@@ -114,7 +113,7 @@ class Report(object):
def __init__(self):
self._results = OrderedDict()
self._results = {}
self.active_test = None
self.failed = False
@@ -125,13 +124,13 @@ class Report(object):
for method in dir(self):
if method.startswith('test_') and callable(getattr(self, method)):
test_methods.append(method)
self._results[method] = OrderedDict([
('success', 0),
('info', 0),
('warning', 0),
('failure', 0),
('log', []),
])
self._results[method] = {
'success': 0,
'info': 0,
'warning': 0,
'failure': 0,
'log': [],
}
if not test_methods:
raise Exception("A report must contain at least one test method.")
self.test_methods = test_methods

View File

@@ -6,7 +6,6 @@ import pkgutil
import sys
import traceback
import threading
from collections import OrderedDict
import yaml
from django import forms
@@ -496,7 +495,7 @@ def get_scripts(use_names=False):
Return a dict of dicts mapping all scripts to their modules. Set use_names to True to use each module's human-
defined name in place of the actual module name.
"""
scripts = OrderedDict()
scripts = {}
# Iterate through all modules within the scripts path. These are the user-created files in which reports are
# defined.
for importer, module_name, _ in pkgutil.iter_modules([settings.SCRIPTS_ROOT]):
@@ -510,7 +509,7 @@ def get_scripts(use_names=False):
if use_names and hasattr(module, 'name'):
module_name = module.name
module_scripts = OrderedDict()
module_scripts = {}
script_order = getattr(module, "script_order", ())
ordered_scripts = [cls for cls in script_order if is_script(cls)]
unordered_scripts = [cls for _, cls in inspect.getmembers(module, is_script) if cls not in script_order]

View File

@@ -1,5 +1,3 @@
from collections import OrderedDict
from django import template
from django.contrib.contenttypes.models import ContentType
from django.utils.safestring import mark_safe
@@ -50,7 +48,7 @@ def custom_links(context, obj):
'perms': context['perms'], # django.contrib.auth.context_processors.auth
}
template_code = ''
group_names = OrderedDict()
group_names = {}
for cl in custom_links: