diff options
| author | Scott Bahling <sbahling@suse.com> | 2020-01-21 12:48:42 +0100 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.com> | 2020-01-21 12:48:42 +0100 |
| commit | aab8651b3caf0d06446e750378ef227d1cdbaa35 (patch) | |
| tree | 2a2360193413ee8c8765add9132bac7801d4be9c | |
| parent | 21a29a084ace36023b266a922b8bbd79136bf7c9 (diff) | |
| download | obsapi-aab8651b3caf0d06446e750378ef227d1cdbaa35.tar.gz obsapi-aab8651b3caf0d06446e750378ef227d1cdbaa35.tar.xz obsapi-aab8651b3caf0d06446e750378ef227d1cdbaa35.zip | |
Add get_spec_files method
| -rw-r--r-- | obsapi/core.py | 11 | ||||
| -rw-r--r-- | test/test_api.py | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/obsapi/core.py b/obsapi/core.py index 58ffb79..443e593 100644 --- a/obsapi/core.py +++ b/obsapi/core.py @@ -389,3 +389,14 @@ class ObsApi(object): etree.SubElement(meta, 'group', groupid=groupid, role=role) return self.put_meta(prj, pkg, etree.tostring(meta)) + + def get_spec_files(self, prj, pkg=None): + if pkg is not None: + pkgs = [pkg] + else: + pkgs = self.ls(prj) + for pkg in pkgs: + d, flist = self.ls(prj, pkg) + for srcfile in flist: + if srcfile.name.endswith('.spec'): + yield self.source.get(prj, pkg, srcfile.name) diff --git a/test/test_api.py b/test/test_api.py index e5a82df..6992492 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -120,3 +120,11 @@ def test_get_groups(): groups = api.get_groups(prj) print groups assert groups == [] + + +def test_get_spec_files(): + for specfile in api.get_spec_files(prj, pkg): + assert 'Name:' in specfile + assert 'Summary:' in specfile + assert '%description' in specfile + assert '%setup' in specfile |
