Package¶
The Data Package model allows to manipulate a Pydantic model in Python according to the Data Package specification
Usage¶
from dplib.models import Package, Resource
package = Package()
package.name = 'name'
package.add_resource(Resource(name='table', path='table.csv'))
print(package.to_text(format="json"))
Reference¶
dplib.models.Package
¶
Bases: Model
Data Package model
Source code in dplib/models/package/package.py
15 16 17 18 19 20 21 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 |
|
basepath: Optional[str] = pydantic.Field(default=None, exclude=True)
class-attribute
instance-attribute
¶
Basepath of the package. All the resources are relative to this path.
contributors: List[Contributor] = []
class-attribute
instance-attribute
¶
The people or organizations who contributed to this Data Package.
created: Optional[str] = None
class-attribute
instance-attribute
¶
The datetime on which this was created.
description: Optional[str] = None
class-attribute
instance-attribute
¶
A description of the package. The description MUST be markdown formatted — this also allows for simple plain text as plain text is itself valid markdown.
homepage: Optional[str] = None
class-attribute
instance-attribute
¶
A URL for the home on the web that is related to this data package.
id: Optional[str] = None
class-attribute
instance-attribute
¶
A property reserved for globally unique identifiers. Examples of identifiers that are unique include UUIDs and DOIs.
image: Optional[str] = None
class-attribute
instance-attribute
¶
An image to use for this data package. For example, when showing the package in a listing.
keywords: List[str] = []
class-attribute
instance-attribute
¶
An Array of string keywords to assist users searching for the package in catalogs.
licenses: List[License] = []
class-attribute
instance-attribute
¶
The license(s) under which the package is provided. This property is not legally binding and does not guarantee the package is licensed under the terms defined in this property.
name: Optional[str] = None
class-attribute
instance-attribute
¶
A short url-usable (and preferably human-readable) name of the package. This MUST be lower-case and contain only alphanumeric characters along with ”.”, ”_” or ”-” characters.
profile: str = pydantic.Field(default=settings.PROFILE_CURRENT_PACKAGE, alias='$schema')
class-attribute
instance-attribute
¶
A profile URL
resources: List[Resource] = []
class-attribute
instance-attribute
¶
List of resources
sources: List[Source] = []
class-attribute
instance-attribute
¶
The raw sources for this data package.
title: Optional[str] = None
class-attribute
instance-attribute
¶
A string providing a title or one sentence description for this package
version: Optional[str] = None
class-attribute
instance-attribute
¶
A version string identifying the version of the package. It should conform to the Semantic Versioning requirements
add_resource(resource)
¶
Add a resource to the package
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource |
Resource
|
The resource to add |
required |
dereference()
¶
Dereference the package It will dereference all the resource's dialects and schemas in the package.
get_resource(*, name=None, path=None)
¶
Get a resource by name or path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Optional[str]
|
The name of the resource |
None
|
path |
Optional[str]
|
The path of the resource |
None
|
Returns:
Type | Description |
---|---|
Optional[Resource]
|
The resource if found |
Source code in dplib/models/package/package.py
model_post_init(_)
¶
dplib.models.License
¶
Bases: Model
Source code in dplib/models/license.py
dplib.models.Source
¶
Bases: Model
Source code in dplib/models/source.py
dplib.models.Contributor
¶
Bases: Model