diff --git a/conan/api/model/list.py b/conan/api/model/list.py index 8faedec405d..6cdc38c3858 100644 --- a/conan/api/model/list.py +++ b/conan/api/model/list.py @@ -225,12 +225,13 @@ def split(self): result.append(subpkglist) return result - def only_recipes(self): - result = {} + def only_recipes(self) -> None: + """ Filter out all the packages and package revisions, keep only the recipes and + recipe revisions in self.recipes. + """ for ref, ref_dict in self.recipes.items(): for rrev_dict in ref_dict.get("revisions", {}).values(): rrev_dict.pop("packages", None) - return result def add_refs(self, refs): # RREVS alreday come in ASCENDING order, so upload does older revisions first diff --git a/test/unittests/model/test_list.py b/test/unittests/model/test_list.py new file mode 100644 index 00000000000..96799f43afa --- /dev/null +++ b/test/unittests/model/test_list.py @@ -0,0 +1,49 @@ +from conan.api.model import PackagesList + + +def test_package_list_only_recipes(): + pl = PackagesList() + pl.recipes = { + "foobar/0.1.0": {'revisions': + {'85eb0587a3c12b90216c72070e9eef3e': + {'timestamp': 1740151190.975, + 'packages': {'c29f32beda3c361f536ba35aae5e876faf970169': + {'revisions': { + '9a0569c04839fff6a6e8f40e10434bc6': + {'timestamp': 1742417567.684486}}, + 'info': {}}}}}}, + "qux/0.2.1": {'revisions': + {'71c3c11b98a6f2ae11f0f391f5e62e2b': + {'timestamp': 1740151186.976, 'packages': + {'13be611585c95453f1cbbd053cea04b3e64470ca': + {'revisions': {'5c7e0c0788cd4d89249ad251f0868787': + {'timestamp': 1740152032.884}}, + 'info': + {'settings': + {'arch': 'x86_64', + 'build_type': 'Release', + 'compiler': 'gcc', + 'compiler.cppstd': '17', + 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '11', 'os': 'Linux'}, + 'options': {'fPIC': 'True', 'shared': 'False'}}}, + '30652ea35b512fa3fe0f4dcd39ad217e4e60bd01': + {'revisions': {'8f363f1d95ad766ac400e1f1f5406599': + {'timestamp': 1741861639.2198145}}, + 'info': {}}, + 'fc491156b442836722612d1aa8a8c57e406447b6': + {'revisions': {'62e9e2659596c97cd1dd313d4394e947': + {'timestamp': 1740151900.394}}, + 'info': { + 'settings': + {'arch': 'x86_64', 'build_type': 'Release', + 'compiler': 'gcc', 'compiler.cppstd': '17', + 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '11', 'os': 'Linux'}, + 'options': {'shared': 'True'}}}}}}} + } + pl.only_recipes() + assert pl.recipes == {'foobar/0.1.0': { + 'revisions': {'85eb0587a3c12b90216c72070e9eef3e': {'timestamp': 1740151190.975}}}, + 'qux/0.2.1': {'revisions': { + '71c3c11b98a6f2ae11f0f391f5e62e2b': {'timestamp': 1740151186.976}}}}