Skip to content

Process multiple input files and support folder hierarchies

Viktor Rosenfeld requested to merge 12-multiple-files into main

This PR changes the logic of the -i parameter to support input folders. If the argument is an input folder, all YAML files inside that folder are added as input files. Subfolders are processed recursively. Furthermore, it is possible to specify the -i parameter multiple times to process multiple files/folders.

This strategy corresponds to option 4 in #12 (closed).

This implementation has the drawback that the image paths specified in YAML files contained in folders/subfolders must be specified relative to the working directory from which Moodle tools is called. There is an initial test which verifies this behavior.

However, it would be better to make image paths relative to YAML file. This requires replacing the transformation of the input paths to TextIOBase objects with os.path objects in iterate_inputs, in order to retain the path information. This could be done in a subsequent PR.

Update: @lennart.behme Added code to make the paths used by assets relative.

Closes #12 (closed)

Edited by Viktor Rosenfeld

Merge request reports

Loading