|
|
@@ -470,7 +470,6 @@ def get_scripts(use_names=False):
|
|
|
defined name in place of the actual module name.
|
|
|
"""
|
|
|
scripts = OrderedDict()
|
|
|
-
|
|
|
# Iterate through all modules within the reports path. These are the user-created files in which reports are
|
|
|
# defined.
|
|
|
for importer, module_name, _ in pkgutil.iter_modules([settings.SCRIPTS_ROOT]):
|
|
|
@@ -478,11 +477,14 @@ def get_scripts(use_names=False):
|
|
|
if use_names and hasattr(module, 'name'):
|
|
|
module_name = module.name
|
|
|
module_scripts = OrderedDict()
|
|
|
- for name, cls in inspect.getmembers(module, is_script):
|
|
|
- module_scripts[name] = cls
|
|
|
+ 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]
|
|
|
+ for cls in [*ordered_scripts, *unordered_scripts]:
|
|
|
+ module_scripts[cls.__name__] = cls
|
|
|
if module_scripts:
|
|
|
scripts[module_name] = module_scripts
|
|
|
-
|
|
|
+
|
|
|
return scripts
|
|
|
|
|
|
|