gamspreprocessor.projectsplitter¶
Splits up a directory structure typically used for GAMS 3 ingest into object directories expected by the SIP packager of GAMS 5.
If an object already exists in a GAMS3 repository, using the gamspreprocessor.gams3 exporter might be easier to use.
The important functions API wise are:
- split_project_files() - Split one or more source files into object directories.
- list_unhandled() - Return files that are still unhandled in the given object directory tree.
gamspreprocessor.projectsplitter
¶
Split project files into objects directories.
This package contains modules for splitting up project folders into object directories.
BookKeeper
¶
A class to keep track of files that have been processed.
As the project dir also contains referenced data streams (images, etc.), we need to keep track of which files have been processed and which have not. It important for the incremental processing of the project that the user can find out which files have not been processed yet.
Initialize the BookKeeper object.
'data_path' is the path to the file where the bookkeeping data is stored.
If you plan to run the splitter multiple times for a single project, make sure that the 'data_path' is the same for all runs.
add_pid
¶
Mark a file as used for an object with ID pid.
As a file can be used by more than one object, we keep the objects it is referenced in as list of object pids.
remove_pid
¶
Remove object ID pid from all entries.
The is useful if an existing object is replaced by a new one.
get_unhandled
¶
Return a list of paths for all files that have not been consumed yet.
update
¶
Merge already registered files with newly collected files.
Also remove files which have been deleted since last run. 'project_path' is the root directory of the project files.
ProjectSplitter
¶
Class to split a project into single objects.
Provides as split method to create a object folder for the file given as argument.
Initialize the ProjectSplitter.
Arguments: output_dir: The directory where the object directories will be created. project_dir: The directory containing the original data. replace_existing_object_dirs: If True, existing object directories will be replaced. Default is False.
replace_existing_object_dirs
instance-attribute
¶
make_object_source
¶
ObjectSource factory.
Return an ObjectSource or a subclass of ObjectSource representing the source file. The type of the returned class depends on mimetype and objecttype.
Raises a FileExistsError if the directory already exists (ie. the object has already been split).
split
¶
Convert sourcefile into an object directory.
Arguments: sourcefile: Path to the source file to be processed. objecttype: The format to use for the source file. Can be 'auto', 'tei' or 'lido'. strip_prefix: If True, the prefix of the pid ('o:') will be removed.
Return a list files (Path objects) which have been copied to the object directory.
update_bookkeeper
¶
Update the bookkeeper with all files in the project directory.
list_unhandled_files
¶
Return files that are still unhandled in the given object directory tree.
split_project_files
¶
split_project_files(output_dir, sourcefiles, object_format='auto', reset=False, replace=False, strip_prefix=False)
Split one or more source files into object directories.
Returns a tuple with the number of object directories created and the number of files copied into those directories.