From 8d458f10ac370c334a2473632af8ff5617d79b48 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 6 Jan 2019 11:02:54 -0500 Subject: [PATCH] Refactor get_dirs --- core/utils/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/utils/__init__.py b/core/utils/__init__.py index 724c85fe..f0c822cc 100644 --- a/core/utils/__init__.py +++ b/core/utils/__init__.py @@ -162,15 +162,16 @@ def process_dir(path, link): def get_dirs(section, subsection, link='hard'): to_return = [] + watch_directory = core.CFG[section][subsection]['watch_dir'] + directory = os.path.join(watch_directory, subsection) + + if not os.path.exists(directory): + directory = watch_directory + try: - watch_dir = os.path.join(core.CFG[section][subsection]['watch_dir'], subsection) - if os.path.exists(watch_dir): - to_return.extend(process_dir(watch_dir, link)) - elif os.path.exists(core.CFG[section][subsection]['watch_dir']): - to_return.extend(process_dir(core.CFG[section][subsection]['watch_dir'], link)) + to_return.extend(process_dir(directory, link)) except Exception as e: - logger.error('Failed to add directories from {0} for post-processing: {1}'.format - (core.CFG[section][subsection]['watch_dir'], e)) + logger.error('Failed to add directories from {0} for post-processing: {1}'.format(watch_directory, e)) if core.USELINK == 'move': try: