Skip to content

Commit

Permalink
ENH: Add default implementations of File
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed May 2, 2023
1 parent 2e2e95a commit 8ca4ee7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bids_ng/types/api1.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ class File(Protocol[SchemaT]):
"""

path: Path
relative_path: Path
dataset: Optional["BIDSDataset[SchemaT]"]

def __fspath__(self) -> str:
...
return str(self.path)

@property
def relative_path(self) -> Path:
if self.dataset is None:
raise ValueError("No dataset root to construct relative path from")
return self.path.relative_to(self.dataset.root)


class BIDSFile(File[SchemaT], Protocol):
Expand Down

0 comments on commit 8ca4ee7

Please sign in to comment.