summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-10-23 15:22:34 +0200
committerMichał Górny <mgorny@gentoo.org>2017-10-23 15:22:34 +0200
commit73bef6c40df0c8c8ba0e00916773688a309685ce (patch)
tree2a57fa01d6b7f8335c1c304dcd8da34738d63fa7
parent45aab84447607060e84110c917dcc0487b4cd2c8 (diff)
downloadgemato-73bef6c40df0c8c8ba0e00916773688a309685ce.tar.gz
manifest: Support finding Manifests for path
-rw-r--r--gemato/manifest.py13
-rw-r--r--tests/test_manifest.py8
2 files changed, 21 insertions, 0 deletions
diff --git a/gemato/manifest.py b/gemato/manifest.py
index 5e06937..d094c87 100644
--- a/gemato/manifest.py
+++ b/gemato/manifest.py
@@ -356,3 +356,16 @@ class ManifestFile(object):
if e.path == filename:
return e
return None
+
+ def find_manifests_for_path(self, path):
+ """
+ Find all MANIFEST entries that could affect the path @path
+ and return an iterator over them. Yield an empty list when
+ there are no matching MANIFEST entries.
+ """
+
+ for e in self.entries:
+ if isinstance(e, ManifestEntryMANIFEST):
+ mdir = os.path.dirname(e.path)
+ if path.startswith(mdir + '/'):
+ yield e
diff --git a/tests/test_manifest.py b/tests/test_manifest.py
index 907da1a..feb4060 100644
--- a/tests/test_manifest.py
+++ b/tests/test_manifest.py
@@ -90,6 +90,14 @@ class ManifestTest(unittest.TestCase):
self.assertIsNone(m.find_dist_entry('myebuild-0.ebuild'))
self.assertEqual(m.find_dist_entry('mydistfile.tar.gz').path, 'mydistfile.tar.gz')
+ def test_find_manifests_for_path(self):
+ m = gemato.manifest.ManifestFile()
+ m.load(io.StringIO(TEST_MANIFEST))
+ self.assertListEqual(list(m.find_manifests_for_path('foo')), [])
+ self.assertListEqual(list(m.find_manifests_for_path('eclass')), [])
+ self.assertListEqual(list(m.find_manifests_for_path('eclass/foo.eclass')),
+ [m.find_path_entry('eclass/Manifest')])
+
class ManifestEntryTest(unittest.TestCase):
"""