Zum Inhalt

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 @task that, for each article in article_list, creates a temp folder named temp-<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 simple os.listdir + os.path.isdir filter.

  • This function from this file is still imported (but unused) by some of the modules that were developed early (for eg, copernicus/tasks.py and mdpi/tasks.py import this, however it is ultimately unused).

identify_articles_without_module_subfolder()

  • Parameters: data_root, issn_list, folder_name

  • Context for Use:

  • A Prefect @task that, for a list of ISSNs, checks each article folder for the presence of a subfolder matching folder_name (via glob.glob), and returns the list of article folders that don't have one.