diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-22 23:09:28 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-22 23:09:28 +0200 |
commit | 49579c0b949952fdf4710c58c6c797cac6b9b582 (patch) | |
tree | 42852025c5b6bcb0bd04a43864fa8e332aa81337 | |
parent | 3b75ac6544c2b863c9b8d6e6c1758f673aa9159f (diff) | |
download | gemato-49579c0b949952fdf4710c58c6c797cac6b9b582.tar.gz |
manifest: Support finding the timestamp
-rw-r--r-- | gemato/manifest.py | 11 | ||||
-rw-r--r-- | tests/test_manifest.py | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/gemato/manifest.py b/gemato/manifest.py index 2c1f4b7..b0168a0 100644 --- a/gemato/manifest.py +++ b/gemato/manifest.py @@ -314,6 +314,17 @@ class ManifestFile(object): for e in self.entries: f.write(u' '.join(e.to_list()) + '\n') + def find_timestamp(self): + """ + Find a timestamp entry and return it. Returns None if there + is no timestamp. + """ + + for e in self.entries: + if isinstance(e, ManifestEntryTIMESTAMP): + return e + return None + def find_path_entry(self, path): """ Find a matching entry for path @path and return it. Returns diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 5e72a8a..43c7e18 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -58,6 +58,12 @@ class ManifestTest(unittest.TestCase): m.dump(outf) self.assertEqual(outf.getvalue().strip(), TEST_DEPRECATED_MANIFEST.strip()) + def test_find_timestamp(self): + m = gemato.manifest.ManifestFile() + m.load(io.StringIO(TEST_MANIFEST)) + self.assertEqual(m.find_timestamp().ts, + datetime.datetime(2017, 10, 22, 18, 06, 41)) + def test_find_path_entry(self): m = gemato.manifest.ManifestFile() m.load(io.StringIO(TEST_MANIFEST)) |