From 0a58b6b6a02764cab0a5ddac8ad9e41898015432 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:40:02 -0500 Subject: [PATCH] Refactor section configuration --- core/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index be1fa13e..d6e61db1 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -921,6 +921,19 @@ def configure_torrent_class(): TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT) +def configure_sections(section): + global SECTIONS + global CATEGORIES + # check for script-defied section and if None set to allow sections + SECTIONS = CFG[ + tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) + if not section else (section,) + ] + for section, subsections in SECTIONS.items(): + CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) + CATEGORIES = list(set(CATEGORIES)) + + def initialize(section=None): global SHOWEXTRACT global CATEGORIES @@ -1051,12 +1064,7 @@ def initialize(section=None): logger.warning('Failed to locate ffprobe. Video corruption detection disabled!') logger.warning('Install ffmpeg with x264 support to enable this feature ...') - # check for script-defied section and if None set to allow sections - SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)] - for section, subsections in SECTIONS.items(): - CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) - CATEGORIES = list(set(CATEGORIES)) - + configure_sections(section) configure_torrent_class() # finished initalizing