API
rdfcrate.wrapper.RoCrate
dataclass
Abstract class containing common functionality for both attached and detached RO-Crates
graph: Graph = field(init=False, default_factory=Graph)
class-attribute
instance-attribute
rdflib.Graph
containing the RO-Crate metadata. This can be accessed directly, but it is recommended to use the other methods provided by this class where available.
version: SpecVersion = field(kw_only=True, default=ROCrate1_1)
class-attribute
instance-attribute
Version of the RO-Crate specification to use
add_entity(id: IdentifiedNode, type: Type, attrs: Attributes = []) -> IdentifiedNode
Adds any type of entity to the crate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
IdentifiedNode
|
ID of the entity being added |
required |
type
|
Type
|
Type of the entity being added |
required |
attrs
|
Attributes
|
Attributes of the entity being added |
[]
|
Returns:
Type | Description |
---|---|
IdentifiedNode
|
The ID of the new entity |
add_metadata(entity: IdentifiedNode, attrs: Attributes) -> IdentifiedNode
Add metadata for an existing entity.
Returns:
Type | Description |
---|---|
IdentifiedNode
|
The ID of the updated entity |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity
|
IdentifiedNode
|
ID of the entity being described |
required |
attrs
|
Attributes
|
Attributes of the entity being described |
required |
compile() -> str
Compiles the RO-Crate to a JSON-LD string
register_dir(path: str, attrs: Attributes = {}, **kwargs: Any) -> IdentifiedNode
Adds metadata for a directory
Returns:
Type | Description |
---|---|
IdentifiedNode
|
The ID of the new directory entity |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the directory, which must be within the crate root |
required |
attrs
|
Attributes
|
Attributes used to describe the |
{}
|
register_file(path: str, attrs: Attributes = [], guess_mime: bool = True, **kwargs: Any) -> IdentifiedNode
Adds file metadata to the crate
Returns: The ID of the new file entity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path or URL to the file being added |
required |
attrs
|
Attributes
|
Attributes used to describe the |
[]
|
guess_mime
|
bool
|
If true, automatically guess and document the MIME type of the file based on its extension |
True
|
rdfcrate.AttachedCrate
dataclass
Bases: RoCrate
See https://www.researchobject.org/ro-crate/specification/1.2-DRAFT/structure#attached-ro-crate
root: Path = field(init=False)
class-attribute
instance-attribute
The RO-Crate directory
register_dir(path: Path | str, attrs: Attributes = [], recursive: bool = False, **kwargs: Any)
See RoCrate.register_dir
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recursive
|
bool
|
If true, register all files and subdirectories in the directory. The automatically created children will only have default metadata.
You can use |
False
|
register_file(path: Path | str, attrs: Attributes = [], guess_mime: bool = True, add_size: bool = False, **kwargs: Any)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
add_size
|
bool
|
If true, automatically add the size of the file to the metadata |
False
|
write()
Writes the RO-Crate to ro-crate-metadata.json
rdfcrate.uris
URIs for RO-Crate
rdfcrate.bioschemas
URIs for Bioschemas
rdfcrate.spec_version
Contains objects representing the different versions of the RO-Crate specification.
Attributes:
Name | Type | Description |
---|---|---|
ROCrate0_2 |
SpecVersion
|
RO-Crate 0.2 |
ROCrate1_0 |
SpecVersion
|
RO-Crate 1.0 |
ROCrate1_1 |
SpecVersion
|
RO-Crate 1.1 |
ROCrate1_2 |
SpecVersion
|
RO-Crate 1.2 |