The objectdir module¶
This module provides some functions to deal with GAMS object directories
gamslib.objectdir
¶
Module for object directory management and validation in GAMS library.
ObjectDirectoryValidationError
¶
Bases: Exception
Exception raised when an object directory is invalid.
is_object_folder
¶
find_object_folders
¶
Find all object folders in the root folder or below.
| PARAMETER | DESCRIPTION |
|---|---|
root_folder
|
Root directory to search for object folders.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
Path
|
Path to each object folder containing a DC.xml file.
TYPE::
|
Notes
- Skips folders that do not contain a DC.xml file and logs a warning.
validate_directory_structure
¶
Validate the structure of the object directory.
Structure is valid if it contains at least these files
- DC.xml
- object.csv
- datastreams.csv
- all files referenced in datastreams.csv
| PARAMETER | DESCRIPTION |
|---|---|
object_path
|
Path to the object directory.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ObjectDirectoryValidationError
|
If the directory structure is invalid. |
validate_main_resource_id
¶
Validate if the main resource file has the same ID as the object directory
Raise a ObjectDirectoryValidationError if the main resource is a TEI or LIDO file and the ID in this file does not have the same ID as the object directory.
In all other cases, this function does not raise an error.
| PARAMETER | DESCRIPTION |
|---|---|
object_dir
|
Path to the object directory.
TYPE:
|
Raises: ObjectDirectoryValidationError: If the main resource file has the same ID as the object directory
validate_csv_files
¶
Validate the CSV files in the object directory.
| PARAMETER | DESCRIPTION |
|---|---|
object_path
|
Path to the object directory.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ObjectDirectoryValidationError
|
If any CSV file is invalid. |
validate_dc_file
¶
Validate the DC.xml file in the object directory.
| PARAMETER | DESCRIPTION |
|---|---|
object_path
|
Path to the object directory.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ObjectDirectoryValidationError
|
If the DC.xml file is invalid. |
validate_object_dir
¶
Check if everything needed is present in the object directory.
| PARAMETER | DESCRIPTION |
|---|---|
object_path
|
Path to the object directory.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ObjectDirectoryValidationError
|
If the directory or required files are missing, or if object.csv is invalid. |