Skip to content

Commit

Permalink
stat: add .last_modified to returned namedtuple
Browse files Browse the repository at this point in the history
This is the same as mtime, for consistency with `last_updated` and
`created`.
  • Loading branch information
OddBloke committed Sep 29, 2022
1 parent da31f53 commit 2f120f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ def _get_base_url(self, url):
"children",
"repo",
"created",
"last_modified",
"last_updated",
],
)
Expand Down Expand Up @@ -887,9 +888,10 @@ def stat(self, pathobj):
checksums = jsn.get("checksums", {})

ctime = dateutil.parser.parse(jsn["created"])
mtime = dateutil.parser.parse(jsn["lastModified"])
stat = ArtifactoryFileStat(
ctime=ctime,
mtime=dateutil.parser.parse(jsn["lastModified"]),
mtime=mtime,
created_by=jsn.get("createdBy"),
modified_by=jsn.get("modifiedBy"),
mime_type=jsn.get("mimeType"),
Expand All @@ -901,6 +903,7 @@ def stat(self, pathobj):
children=children,
repo=jsn.get("repo", None),
created=ctime,
last_modified=mtime,
last_updated=dateutil.parser.parse(jsn["lastUpdated"]),
)

Expand Down Expand Up @@ -1589,7 +1592,7 @@ def stat(self, pathobj=None):
The following fields are available:
created -- file creation time
mtime -- file modification time
last_modified -- file modification time
last_updated -- artifact update time
created_by -- original uploader
modified_by -- last user modifying the file
Expand All @@ -1601,6 +1604,7 @@ def stat(self, pathobj=None):
is_dir -- 'True' if path is a directory
children -- list of children names
ctime -- file creation time (an alias for .created)
mtime -- file modification time (an alias for .last_modified)
"""
pathobj = pathobj or self
return self._accessor.stat(pathobj=pathobj)
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_artifactory_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ def test_stat(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_modified, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
Expand Down Expand Up @@ -541,6 +544,9 @@ def test_stat(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-18T15:35:29.361+04:00")
)
self.assertEqual(
stats.last_modified, dateutil.parser.parse("2014-02-18T15:35:29.361+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-18T15:35:29.361+04:00")
)
Expand Down Expand Up @@ -609,6 +615,9 @@ def test_stat_no_sha256(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_modified, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
Expand Down

0 comments on commit 2f120f3

Please sign in to comment.