Zenodo¶
Zenodo plugin provides Package and Resource models and converters between Zenodo and Data Package notations
Installation¶
Not extra dependencies are required
Usage¶
Converting a Zenodo descriptor to the Data Package notation:
from dplib.plugins.zenodo.models import ZenodoPackage
package = ZenodoPackage.from_path("data/plugins/zenodo/package.json").to_dp()
print(package.to_text(format='json'))
{
"resources": [
{
"name": "fishway_obstruction_data_v1",
"path": "Fishway_Obstruction_Data_v1.csv",
"format": "csv",
"mediatype": "text/csv",
"bytes": 1377,
"hash": "7bdef6756c84c3aea749f8211c557684"
},
{
"name": "readme",
"path": "readme.md",
"format": "md",
"mediatype": "application/octet-stream",
"bytes": 1577,
"hash": "a23a3c99befca45e706c9343e39f5926"
}
],
"id": "https://doi.org/10.5281/zenodo.5770714",
"title": "Fishway_Obstruction_Data_v1.csv",
"description": "<p>This dataset contains pool-weir type fishway (sumerged notch and orifice) hydraulic scenarios with and without obstruction events in accordance with the publication: </p>\n\n<p>Fuentes-Pérez, J.F., García-Vega, A., Bravo-Córdoba, F.J., Sanz-Ronda, F.J. 2021. A Step to Smart Fishways: An Autonomous Obstruction Detection System Using Hydraulic Modeling and Sensor Networks. Sensors 2021, 21(20), 6909.</p>",
"homepage": "https://zenodo.org/api/records/5770714",
"version": "v1",
"contributors": [
{
"title": "Fuentes-P\u00e9rez, Juan Francisco",
"role": "personal",
"organization": "Department of Hydraulics and Hydrology, ETSIIAA, University of Valladolid, 34004 Palencia, Spain"
}
],
"keywords": [
"fishways",
"hydraulics",
"smart fishways",
"pool-weir",
"hydrological variability",
"nonuniformity",
"clogging",
"water-level sensors"
],
"created": "2021-12-10T05:47:07.709885+00:00"
}
Converting a Data Package to Zenodo notation:
from dplib.models import Package
from dplib.plugins.zenodo.models import ZenodoPackage
package = ZenodoPackage.from_dp(Package.from_path("data/package.json"))
print(package.to_text(format="xml"))
Reference¶
dplib.plugins.zenodo.models.ZenodoPackage
¶
Bases: Model
Zenodo Package model
Source code in dplib/plugins/zenodo/models/package.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
created: Optional[str] = None
class-attribute
instance-attribute
¶
files: ZenodoFiles = pydantic.Field(default_factory=ZenodoFiles)
class-attribute
instance-attribute
¶
id: Optional[str] = None
class-attribute
instance-attribute
¶
links: Dict[str, str] = {}
class-attribute
instance-attribute
¶
metadata: ZenodoMetadata = pydantic.Field(default_factory=ZenodoMetadata)
class-attribute
instance-attribute
¶
pids: Dict[str, ZenodoPid] = {}
class-attribute
instance-attribute
¶
updated: Optional[str] = None
class-attribute
instance-attribute
¶
from_dp(package)
classmethod
¶
Create a Zenodo Package from Data Package
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package |
Package
|
Data Package |
required |
Returns:
Type | Description |
---|---|
ZenodoPackage
|
Zenodo Package |
Source code in dplib/plugins/zenodo/models/package.py
to_dp()
¶
Convert to Data Package
Returns:
Type | Description |
---|---|
Package
|
Data Package |
Source code in dplib/plugins/zenodo/models/package.py
dplib.plugins.zenodo.models.ZenodoResource
¶
Bases: Model
Zenodo Resource model
Source code in dplib/plugins/zenodo/models/resource.py
checksum: Optional[str] = None
class-attribute
instance-attribute
¶
ext: Optional[str] = None
class-attribute
instance-attribute
¶
id: Optional[str] = None
class-attribute
instance-attribute
¶
key: str
instance-attribute
¶
mimetype: Optional[str] = None
class-attribute
instance-attribute
¶
size: Optional[int] = None
class-attribute
instance-attribute
¶
from_dp(resource)
classmethod
¶
Create Zenodo Resource from Data Resource
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource |
Resource
|
Data Resource |
required |
Returns:
Type | Description |
---|---|
Optional[ZenodoResource]
|
Zenodo Resource |
Source code in dplib/plugins/zenodo/models/resource.py
to_dp(*, package_id)
¶
Convert to Data Package resource
Returns:
Type | Description |
---|---|
Resource
|
Data Resource |