Skip to content

Commit

Permalink
Merge pull request #47 from gerlero/cases
Browse files Browse the repository at this point in the history
Update TimeDirectory
  • Loading branch information
gerlero authored Mar 28, 2024
2 parents 39e5d0c + 47fe8c9 commit 23e3332
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions foamlib/_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def __getitem__(self, key: str) -> FoamFieldFile:
except FileNotFoundError as e:
raise KeyError(key) from e

def __contains__(self, obj: object) -> bool:
if isinstance(obj, FoamFieldFile):
return obj.path.parent == self.path
elif isinstance(obj, str):
return (self.path / obj).is_file()
else:
return False

def __iter__(self) -> Iterator[FoamFieldFile]:
for p in self.path.iterdir():
if p.is_file():
Expand Down

0 comments on commit 23e3332

Please sign in to comment.