common.directory
Overview
common/directory.py is a small collection of initially prototyped folder-related helper functions.
(Currently, utils.py is the central helper file for folder-related helper functions. Functionalities like get_module_temp_directory, copy_content_from_previous_module, rename_module_temp_directory, etc can be found there.)
The module contains three functions:
create_temporary_directories()
-
Parameters:
article_list(list of article folder paths),module_name(str) -
Context for Use:
-
A Prefect
@taskthat, for each article inarticle_list, creates a temp folder namedtemp-<module_name>-<UTC ISO timestamp>directly inside the article's folder, and returns a list of dicts recording each article's folder, its new temp folder path, and a status code (0= created,1= already existed or failed to create). - Note: This does not match the current folder-naming convention and is replaced by the function in utils.py.
write_names_of_all_subdirectories_to_list()
-
Parameters:
path(a directory path) -
Context for Use:
-
Returns a list of names of every immediate subdirectory of
path, via a simpleos.listdir+os.path.isdirfilter. - This function from this file is still imported (but unused) by some of the modules that were developed early (for eg,
copernicus/tasks.pyandmdpi/tasks.pyimport this, however it is ultimately unused).
identify_articles_without_module_subfolder()
-
Parameters:
data_root,issn_list,folder_name -
Context for Use:
-
A Prefect
@taskthat, for a list of ISSNs, checks each article folder for the presence of a subfolder matchingfolder_name(viaglob.glob), and returns the list of article folders that don't have one.