Skip to content

Commit 95a2496

Browse files
authored
refactor: update to the two datapackage scripts (#16)
1 parent 1c43200 commit 95a2496

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

scripts/create-datapackage-json.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import seedcase_sprout.core as sp
44

5+
default_properties = sp.PackageProperties.default().compact_dict
6+
57
properties = sp.PackageProperties(
8+
**default_properties,
69
name="dung-beetle-activity",
710
title=(
811
"Dung beetle activity affects rainforest seed bank dynamics "
@@ -61,4 +64,7 @@
6164

6265
# Create the path to the package
6366
package_path = Path(__file__).resolve().parent.parent
64-
package_path = sp.create_package_properties(properties=properties, path=package_path)
67+
68+
sp.write_package_properties(
69+
properties=properties, path=sp.PackagePath(package_path).properties()
70+
)

scripts/edit-datapackage-json.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
import seedcase_sprout.core as sp
44

5-
properties = sp.PackageProperties(
5+
package_path = Path(__file__).resolve().parent.parent
6+
7+
current_properties = sp.read_properties(
8+
path=sp.PackagePath(package_path).properties(),
9+
)
10+
11+
updated_properties = sp.PackageProperties(
612
description=(
713
"Dung beetles relocate vertebrate feces under the soil surface, "
814
"and this behavior has many ecological consequences. In tropical forests, "
@@ -11,13 +17,12 @@
1117
),
1218
)
1319

14-
package_path = Path(__file__).resolve().parent.parent / "datapackage.json"
15-
16-
updated_package_properties = sp.edit_package_properties(
17-
path=package_path,
18-
properties=properties,
20+
updated_package_properties = sp.update_package_properties(
21+
current_properties=current_properties,
22+
update_properties=updated_properties,
1923
)
2024

21-
package_path = sp.write_package_properties(
22-
properties=updated_package_properties, path=package_path
25+
sp.write_package_properties(
26+
properties=updated_package_properties,
27+
path=sp.PackagePath(package_path).properties(),
2328
)

0 commit comments

Comments
 (0)