gamspreprocessor.gams3¶
This module exports digital objects from a GAMS3 instance to
object dirs. The most important function is
export_objects(),
a generator function which yields Gams3Object objects
containing data about the export status.
gamspreprocessor.gams3
¶
This module provides the main API forexporting GAMS 3 objects.
Gams3Object
¶
A Fedora 3 object.
Initialize the object with its PID and base URL.
NAMESPACES
class-attribute
¶
object_url
instance-attribute
¶
export
¶
Export this object and its datastreams into an object-specific directory.
This method raises an Export Error if an error occurs during export. The object is aware of its status which can be checked after export: the status attribute has the following possible values implement as ExportStatus Enum:
- ExportStatus.PENDING (initial state),
- ExportStatus.EXPORTED (export successful),
- ExportStatus.REPLACED (existing export was replaced),
- ExportStatus.IGNORED (export skipped due to existing export and overwrite=False),
- ExportStatus.ERROR (an error occurred during export).
You might also want to check the warnings and errors attributes of the object after export, which contain any warnings or errors that occurred during export.
| PARAMETER | DESCRIPTION |
|---|---|
output_root
|
Root directory where the object directory will be created.
TYPE:
|
overwrite
|
Whether to overwrite an existing object directory.
If an object directory already exists at the target location and
TYPE:
|
strip_prefix
|
Whether to strip the "o:" prefix from the PID when naming the subdirectories.
TYPE:
|
colon_replacement
|
String to replace ":" in PIDs when naming subdirectories.
TYPE:
|
Returns: None
| RAISES | DESCRIPTION |
|---|---|
ExportError
|
If an error occurs during export of the object or any of its datastream |
export_objects
¶
export_objects(pid_pattern, output_dir, overwrite=False, base_url='https://gams.uni-graz.at/archive', strip_prefix=False, colon_replacement='%3A')
Export all objects matching the given PID pattern from a GAMS 3 repository.
Yield each exported Gams3Object. Export exceptions are converted to warnings, so you want to check the status attribute of each object. All warnings and errors are also collected in the warnings and errors attributes of each object, respectively.
| PARAMETER | DESCRIPTION |
|---|---|
pid_pattern
|
A pattern to match PIDs, e.g. "o:foo*"
TYPE:
|
output_dir
|
Path to the directory to save the exported objects to.
TYPE:
|
overwrite
|
Whether to overwrite existing object directories and files. If set to False, objects which already exist in the output directory are skipped.
TYPE:
|
base_url
|
Base URL of the GAMS 3 repository, default is "https://gams.uni-graz.at/archive"
TYPE:
|
strip_prefix
|
Whether to strip the type prefix (e.g. o:) from the PID when naming the subdirectories.
TYPE:
|
colon_replacement
|
String to replace ":" in PIDs when naming subdirectories, default is "%3A". Ignored if strip_prefix is True.
TYPE:
|
Yields: Each exported Gams3Object.