Skip to content

Commit a15477b

Browse files
authored
feat: ✨ add possibility to return example path (#29)
# Description @lwjohnst86 You will be happy (I think) to hear that I find a use case for `Example.<name>.path` in our docs. Currently we write ```py !uv run seedcase-flower view {so.Example.flora.address.value} ``` which would be slightly more convenient as ```py !uv run seedcase-flower view {so.Example.flora.path} ``` However, the bigger win that I think justifies having this attribute is that instead of ```py from pathlib import Path print( '```json', Path(so.Example.flora.address.value).read_text(), '```', sep='\n' ) ``` we can simply write ```py print( '```json', so.Example.flora.path.read_text(), '```', sep='\n' ) ``` This pattern occurs a few times in the docs so I think it is worth providing this convenience. Needs a quick review. ## Checklist - [x] Ran `just run-all`
1 parent 8b79300 commit a15477b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/seedcase_soil/example_datapackage.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from enum import StrEnum
44
from importlib.resources import files
5+
from pathlib import Path
56

67
from .parse_source import Address
78

@@ -15,9 +16,14 @@ class Example(StrEnum):
1516
woolly = "woolly"
1617

1718
@property
18-
def address(self) -> Address:
19-
"""Return this example's local `Address`."""
19+
def path(self) -> Path:
20+
"""Return this example's `Path`."""
2021
datapackage_path = files("seedcase_soil").joinpath(
2122
f"example-datapackages/{self.value}.json"
2223
)
23-
return Address(value=str(datapackage_path), local=True)
24+
return Path(str(datapackage_path))
25+
26+
@property
27+
def address(self) -> Address:
28+
"""Return this example's `Address`."""
29+
return Address(value=str(self.path), local=True)

0 commit comments

Comments
 (0)