Skip to content

Commit 5b58421

Browse files
committed
implementing last_modified property
1 parent 7cdebbe commit 5b58421

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

fileformats/core/collection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def contents(self) -> ty.List[FileSet]:
3131
continue
3232
return contnts
3333

34+
# @property
35+
# def last_modified(self) -> int:
36+
# """The latest modification time of all files in the set"""
37+
# return max(c.last_modified for c in self.contents)
38+
3439
@validated_property
3540
def _validate_required_content_types(self) -> None:
3641
not_found = set(self.required_content_types)

fileformats/core/fileset.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ def mtimes(self) -> ty.Tuple[ty.Tuple[str, int], ...]:
260260
"""
261261
return tuple((str(p), p.stat().st_mtime_ns) for p in sorted(self.fspaths))
262262

263+
@property
264+
def last_modified(self) -> int:
265+
"""The latest modification time of all files in the set"""
266+
return max(m for _, m in self.mtimes)
267+
263268
@classproperty # type: ignore[arg-type]
264269
def mime_type(cls) -> str:
265270
"""Generates a MIME type (IANA) identifier from a format class. If an official

0 commit comments

Comments
 (0)