🚧 Sprout is still in active development and evolving quickly, so the documentation and functionality may not work as described and could undergo substantial changes 🚧
core.write_resource_properties
core.write_resource_properties
Functions
Name | Description |
---|---|
get_resource_id_from_properties | Returns the resource ID of the specified resource properties. |
get_resource_properties | Finds the resource properties with the given ID within the given package. |
write_resource_properties | Adds the specified resource properties to the datapackage.json file. |
get_resource_id_from_properties
core.write_resource_properties.get_resource_id_from_properties(
resource_properties, )
Returns the resource ID of the specified resource properties.
Parameters
resource_properties : dict
-
The resource properties object.
Returns
: int
-
The ID of the resource.
Raises
: NotPropertiesError
-
If the resource properties have a malformed or missing data path.
get_resource_properties
core.write_resource_properties.get_resource_properties(
package_properties,
resource_id, )
Finds the resource properties with the given ID within the given package.
Parameters
package_properties : dict
-
The package properties with the resources to look through.
resource_id : int
-
The ID of the resource to find.
Returns
: dict | None
-
The resource with the specified ID, if found. Otherwise returns
None
.
write_resource_properties
core.write_resource_properties.write_resource_properties(
path,
resource_properties, )
Adds the specified resource properties to the datapackage.json
file.
This functions verifies resource_properties
, and if a resource with that ID is already present on the package, the properties of the resource with that ID are updated, with values in resource_properties
overwriting preexisting values. Otherwise, resource_properties
is added as a new resource.
Parameters
path : Path
-
The path to the
datapackage.json
file. resource_properties : dict
-
The resource properties to add.
Returns
: Path
-
The path to the updated
datapackage.json
file.
Raises
: FileNotFound
-
If the
datapackage.json
file doesn’t exist. : NotPropertiesError
-
If the resource or package properties are not correct, i.e., they are incomplete or don’t follow the Data Package specification.
: JSONDecodeError
-
If the
datapackage.json
file couldn’t be read.