Closed jrwdunham closed 6 years ago
The metsrw commit cf12834a137572b3af47be2e9401ce6ab39c3c26 (part of PR #27) introduces functionality that should facilitate the creation of PREMIS plugins that conform to the API declared by the FSEntry class.
I am closing this because the plugin (dependency injection) system seems to address this. The FSEntry
class now declares its dependencies via class methods that valuate to Dependency
instances which are passed assertions about the dependency, e.g.:
>>> premis_object_class = Dependency(
... has_methods('serialize'),
... has_class_methods('fromtree'),
... is_class)
The following PRs introduce PREMIS-related functionality to metsrw:
The Write pointer files PR #27 introduces an informal plugin system that allows metsrw's
METSDocument
class to know how to work with different metadata standards, in this case PREMIS. The API for this plugin system needs to be analyzed and explicitly defined so that it can be used, e.g., to convert PR #20's PREMIS work to a plugin.Here is how the metsrw plugin system currently works. The constructor of the
METSDocument
class now accepts aplugins
kwarg which should be a dict mapping mdType values (e.g.,'PREMIS:OBJECT'
) to classes. Those classes are expected to have a class methodfromtree
which takes anlxml._Element
instance (provided by metsrw'FSEntry
) and returns an instance of the plugin's representation of the metadata element, cf. the PREMISRW plugin. This allows one to callMETSDocument(plugins=my_plugins).get_file(file_uuid=my_file_uuid).get_premis_objects()
and get PREMIS objects as the anticipated type of Python instance.In the other direction,
mets_fs_entry.add_premis_object(premis_object.serialize())
is how a PREMIS metadata element is currently added to an existing metsrwFSEntry
instance.In summary, under the API implicit in PR #27, metadata plugins must be classes that provide:
fromtree
class method that creates an instance given anlxml._Element
instance as input, andserialize
instance method that returns anlxml._Element
instance.This ^ API is definitely not written in stone. But it is a start...