Skip to content
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

[develop2] remove PID timestamps in conan list #12871

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions conan/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,15 @@ def prefs(self):
return prefs

def add_prefs(self, prefs, configurations=None):
confs = configurations or OrderedDict()
confs = configurations or {}
for pref in prefs:
binary_info = confs.get(pref, OrderedDict())
self.recipes.setdefault(pref.ref, []).append((pref, binary_info))

@property
def ordered_recipes_by_name(self):
ret = OrderedDict()
for ref, prefs in self.recipes.items():
ret.setdefault(ref.name, OrderedDict()).setdefault(ref, prefs)
return ret

def serialize(self):
ret = OrderedDict()
for ref, prefs in self.recipes.items():
pref_ret = OrderedDict()
if prefs:
for pref, binary_info in prefs:
pref_ret[pref.repr_notime()] = binary_info
ret[ref.repr_notime()] = pref_ret
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done to avoid failures when converting to JSON. I guess that test test_list_package_info_and_json_format was lost.

ret = {}
for ref, prefs in sorted(self.recipes.items()):
ret.setdefault(ref.name, {})[ref] = prefs
return ret


Expand Down
15 changes: 12 additions & 3 deletions conan/api/subapi/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from conan.api.model import Remote, SelectBundle
from conan.internal.api.select_pattern import ListPatternMode
from conan.internal.conan_app import ConanApp
from conans.errors import ConanException
from conans.errors import ConanException, NotFoundException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.search.search import get_cache_packages_binary_info, filter_packages
Expand Down Expand Up @@ -38,13 +38,16 @@ def recipe_revisions(self, ref: RecipeReference, remote=None):
return results

def latest_package_revision(self, pref: PkgReference, remote=None):
# TODO: This returns None if the given package_id is not existing. It should probably
# raise NotFound, but to keep aligned with the above ``latest_recipe_revision`` which
# is used as an "exists" check too in other places, lets respect the None return
assert pref.revision is None, "latest_package_revision: ref already have a revision"
assert pref.package_id is not None, "package_id must be defined"
app = ConanApp(self.conan_api.cache_folder)
if remote:
ret = app.remote_manager.get_latest_package_reference(pref, remote=remote)
else:
ret = app.cache.get_latest_package_reference(pref)

return ret

def package_revisions(self, pref: PkgReference, remote: Remote=None):
Expand Down Expand Up @@ -132,14 +135,20 @@ def select(self, pattern, package_query=None, remote=None, search_mode=None):
# Show all the package IDs and their configurations
if search_mode == ListPatternMode.SHOW_PACKAGE_IDS:
# add pref and its package configuration
# remove timestamp, as server does not provide it
for p in prefs:
p.timestamp = None
select_bundle.add_prefs(prefs, configurations=packages)
continue

for pref in prefs:
if search_mode in (ListPatternMode.SHOW_LATEST_PREV,
ListPatternMode.SHOW_ALL_PREVS):
if pattern.is_latest_prev:
prevs = [self.conan_api.list.latest_package_revision(pref, remote)]
prev = self.conan_api.list.latest_package_revision(pref, remote)
if prev is None:
raise NotFoundException(f"Binary package not found: '{pref}")
prevs = [prev]
else:
prevs = self.conan_api.list.package_revisions(pref, remote)
prevs = pattern.filter_prevs(prevs)
Expand Down
3 changes: 1 addition & 2 deletions conan/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def list(conan_api: ConanAPI, parser, *args):
except Exception as e:
results[name] = {"error": str(e)}
else:
results[name] = list_bundle.serialize() if args.format in ("json", "html") \
else list_bundle.ordered_recipes_by_name
results[name] = list_bundle.serialize()
return {
"results": results,
"search_mode": ref_pattern.mode,
Expand Down
3 changes: 1 addition & 2 deletions conan/cli/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def search(conan_api: ConanAPI, parser, *args):
except Exception as e:
results[remote.name] = {"error": str(e)}
else:
results[remote.name] = list_bundle.serialize() if args.format == "json" \
else list_bundle.ordered_recipes_by_name
results[remote.name] = list_bundle.serialize()
return {
"results": results,
"search_mode": search_mode,
Expand Down
Loading