-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New pkglist list manipulation command
#16022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
52b3aed
wip
memsharded de3cb17
Merge branch 'release/2.0' into feature/listq
memsharded 76ce356
Merge branch 'release/2.0' into feature/listq
memsharded 1beee4e
wip
memsharded 656389e
Merge branch 'release/2.0' into feature/listq
memsharded c0c54bb
Merge branch 'develop2' into feature/listq
memsharded 958e989
Merge branch 'develop2' into feature/listq
memsharded 70a6cd7
wip
memsharded 863d41c
Merge branch 'develop2' into feature/listq
memsharded 5fa540a
review
memsharded 59f88cd
added from_graph
memsharded fa59514
names
memsharded b0af221
review
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import copy | ||
|
|
||
| from conan.api.conan_api import ConanAPI | ||
| from conan.api.model import MultiPackagesList, PackagesList | ||
| from conan.cli import make_abs_path | ||
| from conan.cli.command import conan_command, conan_subcommand | ||
| from conan.cli.commands.list import print_list_text, print_list_json | ||
| from conan.cli.formatters.list import list_packages_html | ||
| from conans.errors import NotFoundException | ||
|
|
||
|
|
||
| @conan_command(group="Consumer") | ||
| def pkglist(conan_api: ConanAPI, parser, *args): # noqa | ||
| """ | ||
| Several operations over package lists | ||
| """ | ||
|
|
||
|
|
||
| @conan_subcommand(formatters={"text": print_list_text, | ||
| "json": print_list_json, | ||
| "html": list_packages_html}) | ||
| def pkglist_find_remote(conan_api, parser, subparser, *args): | ||
| """ | ||
| (Experimental) Find the remotes of a list of packages in the cache | ||
| """ | ||
| subparser.add_argument('list', help="Input package list") | ||
| subparser.add_argument("-r", "--remote", default=None, action="append", | ||
| help="Remote names. Accepts wildcards " | ||
| "('*' means all the remotes available)") | ||
| args = parser.parse_args(*args) | ||
|
|
||
| listfile = make_abs_path(args.list) | ||
| multi_pkglist = MultiPackagesList.load(listfile) | ||
| package_list = multi_pkglist["Local Cache"] | ||
| selected_remotes = conan_api.remotes.list(args.remote) | ||
|
|
||
| result = MultiPackagesList() | ||
| for r in selected_remotes: | ||
| result_pkg_list = PackagesList() | ||
| for ref, recipe_bundle in package_list.refs().items(): | ||
| ref_no_rev = copy.copy(ref) # TODO: Improve ugly API | ||
| ref_no_rev.revision = None | ||
| try: | ||
| revs = conan_api.list.recipe_revisions(ref_no_rev, remote=r) | ||
| except NotFoundException: | ||
| continue | ||
| if ref not in revs: # not found | ||
| continue | ||
| result_pkg_list.add_refs([ref]) | ||
| for pref, pref_bundle in package_list.prefs(ref, recipe_bundle).items(): | ||
| pref_no_rev = copy.copy(pref) # TODO: Improve ugly API | ||
| pref_no_rev.revision = None | ||
| try: | ||
| prevs = conan_api.list.package_revisions(pref_no_rev, remote=r) | ||
| except NotFoundException: | ||
| continue | ||
| if pref in prevs: | ||
| result_pkg_list.add_prefs(ref, [pref]) | ||
| info = recipe_bundle["packages"][pref.package_id]["info"] | ||
| result_pkg_list.add_configurations({pref: info}) | ||
| if result_pkg_list.recipes: | ||
| result.add(r.name, result_pkg_list) | ||
|
|
||
| return { | ||
| "results": result.serialize(), | ||
| "conan_api": conan_api, | ||
| "cli_args": " ".join([f"{arg}={getattr(args, arg)}" | ||
| for arg in vars(args) if getattr(args, arg)]) | ||
| } | ||
|
|
||
|
|
||
| @conan_subcommand(formatters={"text": print_list_text, | ||
| "json": print_list_json, | ||
| "html": list_packages_html}) | ||
| def pkglist_merge(conan_api, parser, subparser, *args): | ||
| """ | ||
| (Experimental) Merge several package lists into a single one | ||
| """ | ||
| subparser.add_argument("-l", "--list", help="Package list file", action="append") | ||
| args = parser.parse_args(*args) | ||
|
|
||
| result = MultiPackagesList() | ||
| for pkglist in args.list: | ||
| listfile = make_abs_path(pkglist) | ||
| multi_pkglist = MultiPackagesList.load(listfile) | ||
| result.merge(multi_pkglist) | ||
|
|
||
| return { | ||
| "results": result.serialize(), | ||
| "conan_api": conan_api, | ||
| "cli_args": " ".join([f"{arg}={getattr(args, arg)}" | ||
| for arg in vars(args) if getattr(args, arg)]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.