Flatten get_dirs function

This commit is contained in:
Labrys of Knossos 2019-01-06 10:58:02 -05:00
commit e67f29cb7b

View file

@ -79,10 +79,7 @@ def clean_dir(path, section, subsection):
return clean_directory(path, files)
def get_dirs(section, subsection, link='hard'):
to_return = []
def process_dir(path):
def process_dir(path, link):
folders = []
logger.info('Searching {0} for mediafiles to post-process ...'.format(path))
@ -161,12 +158,16 @@ def get_dirs(section, subsection, link='hard'):
folders.extend([directory])
return folders
def get_dirs(section, subsection, link='hard'):
to_return = []
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))
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']))
to_return.extend(process_dir(core.CFG[section][subsection]['watch_dir'], 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))
@ -175,7 +176,7 @@ def get_dirs(section, subsection, link='hard'):
try:
output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection)
if os.path.exists(output_directory):
to_return.extend(process_dir(output_directory))
to_return.extend(process_dir(output_directory, link))
except Exception as e:
logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUTDIRECTORY, e))