From 99829bd8ef50a3083af09a2292bdfb44262363b4 Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 08:56:17 +0100 Subject: [PATCH 1/8] add arch to lookups --- griffon/services/core_queries.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 56a42b7..2cf5401 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -220,7 +220,7 @@ def async_retrieve_sources(self, purl): "limit": 120, "root_components": "True", "provides": purl, - "include_fields": "type,nvr,purl,name,version,namespace,download_url,related_url", + "include_fields": "type,arch,nvr,purl,name,version,namespace,download_url,related_url", } try: return list(self.components.retrieve_list_iterator_async(**params, max_results=5000)) @@ -234,7 +234,7 @@ def async_retrieve_upstreams(self, purl): "limit": 120, "root_components": "True", "upstreams": purl, - "include_fields": "type,nvr,purl,name,version,namespace,download_url,related_url", + "include_fields": "type,arch,nvr,purl,name,version,namespace,download_url,related_url", } try: return list(self.components.retrieve_list_iterator_async(**params, max_results=5000)) From 95ec34a73a5d3f8a9719c80ef26218ddbf6a59ee Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 09:09:43 +0100 Subject: [PATCH 2/8] remove --search-redhat on service products-contains-component --- CHANGELOG.md | 3 +++ griffon/commands/queries.py | 13 ++----------- griffon/services/core_queries.py | 3 --- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f19f2c..32576f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed +* removed --search-redhat on service products-contain-component + ## [0.5.1] - 2024-01-19 ### Changed * --filter-rh-naming enabled by default (GRIF-121) diff --git a/griffon/commands/queries.py b/griffon/commands/queries.py index d5b5ca1..38200ee 100644 --- a/griffon/commands/queries.py +++ b/griffon/commands/queries.py @@ -274,7 +274,7 @@ def retrieve_component_summary(ctx, component_name, strict_name_search, operatio "search_all", is_flag=True, default=False, - help="Search all Components and dependencies.", + help="Flat search for all Components.", ) @click.option( "--search-all-roots", @@ -283,13 +283,6 @@ def retrieve_component_summary(ctx, component_name, strict_name_search, operatio default=False, help="Search all ROOT Components and dependencies.", ) -@click.option( - "--search-redhat", - "search_redhat", - is_flag=True, - default=False, - help="Search all Red Hat root Components and dependencies.", -) @click.option( "--search-community", "search_community", @@ -302,7 +295,7 @@ def retrieve_component_summary(ctx, component_name, strict_name_search, operatio "search_all_upstreams", is_flag=True, default=False, - help="Search for Components by upstream.", + help="Flat search for all Components by upstream.", ) @click.option( "--no-community", @@ -396,7 +389,6 @@ def get_product_contain_component( filter_rh_naming, search_all, search_all_roots, - search_redhat, search_community, search_all_upstreams, no_community, @@ -423,7 +415,6 @@ def get_product_contain_component( and not search_related_url and not search_community and not search_all_upstreams - and not search_redhat and not search_provides and not search_upstreams ): diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 2cf5401..f4db3cc 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -191,7 +191,6 @@ class products_containing_specific_component_query: "search_community", "search_upstreams", "filter_rh_naming", - "search_redhat", "no_community", "no_middleware", "no_upstream_affects", @@ -294,7 +293,6 @@ class products_containing_component_query: "search_all_roots", "search_all_upstreams", "search_related_url", - "search_redhat", "search_community", "search_upstreams", "filter_rh_naming", @@ -321,7 +319,6 @@ def __init__(self, params: dict) -> None: self.search_all = self.params.get("search_all") self.search_all_roots = self.params.get("search_all_roots") self.search_related_url = self.params.get("search_related_url") - self.search_redhat = self.params.get("search_redhat") self.search_community = self.params.get("search_community") self.search_all_upstreams = self.params.get("search_all_upstreams") self.filter_rh_naming = self.params.get("filter_rh_naming") From e3d7abd7ae6d36f9af5011cee2e3b1f778ea6dab Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 09:45:33 +0100 Subject: [PATCH 3/8] minor output tweaks --- griffon/output.py | 90 ++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 52 deletions(-) diff --git a/griffon/output.py b/griffon/output.py index d77cf10..27c126e 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -492,8 +492,8 @@ def text_output_products_contain_component( ) for upstream_component_name in upstream_component_names: console.print( - Text(pv, style="bright_red b"), - upstream_component_name, + Text(pv, style=f"{product_color} b"), + f"[yellow1]{upstream_component_name}[/yellow1]", no_wrap=no_wrap, ) if result_tree[pv][ps][cn][nvr]["sources"]: @@ -511,8 +511,8 @@ def text_output_products_contain_component( ) for source_component_name in source_component_names: console.print( - Text(pv, style="bright_red b"), - source_component_name, + Text(pv, style=f"{product_color} b"), + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", no_wrap=no_wrap, ) if not (result_tree[pv][ps][cn][nvr]["upstreams"]) and not ( @@ -522,6 +522,7 @@ def text_output_products_contain_component( Text(pv, style=f"{product_color} b"), dep, no_wrap=no_wrap, + width=10000, ) if ( ctx.obj["VERBOSE"] == 1 @@ -591,15 +592,13 @@ def text_output_products_contain_component( ) ) if len(upstream_component_names) > 0: - upstream_component_name = ( - f"[cyan]{upstream_component_names[0]}[/cyan]" - ) + upstream_component_name = upstream_component_names[0] if len(upstream_component_names) > 1: - upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa + upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - upstream_component_name, - dep, + f"[yellow1]{upstream_component_name}[/yellow1]", + f"[{dep}]", no_wrap=no_wrap, ) if result_tree[pv][ps][cn][nvr]["sources"]: @@ -616,15 +615,13 @@ def text_output_products_contain_component( ) ) if len(source_component_names) > 0: - source_component_name = ( - f"[red]{source_component_names[0]}[/red]" - ) + source_component_name = source_component_names[0] if len(source_component_names) > 1: - source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa + source_component_name = f"[bright_yellow]{source_component_names[0]} and {len(source_component_names) - 1} more[/bright_yellow]" # noqa console.print( Text(ps, style=f"{product_color} b"), - source_component_name, - dep, + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[{dep}]", no_wrap=no_wrap, ) if not (result_tree[pv][ps][cn][nvr]["upstreams"]) and not ( @@ -645,6 +642,7 @@ def text_output_products_contain_component( dep, child_dep_names, no_wrap=no_wrap, + width=10000, ) if ( ctx.obj["VERBOSE"] == 2 @@ -727,15 +725,13 @@ def text_output_products_contain_component( ) ) if len(upstream_component_names) > 0: - upstream_component_name = ( - f"[cyan]{upstream_component_names[0]}[/cyan]" - ) + upstream_component_name = upstream_component_names[0] if len(upstream_component_names) > 1: - upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa + upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - upstream_component_name, - dep, + f"[yellow1]{upstream_component_name}[/yellow1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, ) @@ -753,15 +749,13 @@ def text_output_products_contain_component( ) ) if len(source_component_names) > 0: - source_component_name = ( - f"[red]{source_component_names[0]}[/red]" - ) + source_component_name = source_component_names[0] if len(source_component_names) > 1: source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa console.print( Text(ps, style=f"{product_color} b"), - source_component_name, - dep, + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, ) @@ -785,7 +779,7 @@ def text_output_products_contain_component( child_dep_names, f"[i][grey]{related_url}[/grey][/i]", f"[i][grey]{build_source_url}[/grey][/i]", - width=1000, + width=10000, no_wrap=no_wrap, ) if ( @@ -841,15 +835,13 @@ def text_output_products_contain_component( ) ) if len(upstream_component_names) > 0: - upstream_component_name = ( - f"[cyan]{upstream_component_names[0]}[/cyan]" - ) + upstream_component_name = upstream_component_names[0] if len(upstream_component_names) > 1: - upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa + upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - upstream_component_name, - dep, + f"[yellow1]{upstream_component_name}[/yellow1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, ) @@ -867,15 +859,13 @@ def text_output_products_contain_component( ) ) if len(source_component_names) > 0: - source_component_name = ( - f"[red]{source_component_names[0]}[/red]" - ) + source_component_name = source_component_names[0] if len(source_component_names) > 1: source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa console.print( Text(ps, style=f"{product_color} b"), - source_component_name, - dep, + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, ) @@ -899,7 +889,7 @@ def text_output_products_contain_component( child_dep_names, f"[i][grey]{related_url}[/grey][/i]", f"[i][grey]{build_source_url}[/grey][/i]", - width=1000, + width=10000, no_wrap=no_wrap, ) if ( @@ -953,15 +943,13 @@ def text_output_products_contain_component( ) ) if len(upstream_component_names) > 0: - upstream_component_name = ( - f"[cyan]{upstream_component_names[0]}[/cyan]" - ) + upstream_component_name = upstream_component_names[0] if len(upstream_component_names) > 1: - upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa + upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b u"), - upstream_component_name, - dep, + f"[yellow1]{upstream_component_name}[/yellow1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", f"[grey]{build_source_url}[/grey]", no_wrap=no_wrap, @@ -980,15 +968,13 @@ def text_output_products_contain_component( ) ) if len(source_component_names) > 0: - source_component_name = ( - f"[red]{source_component_names[0]}[/red]" - ) + source_component_name = source_component_names[0] if len(source_component_names) > 1: - source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa + source_component_name = f"{source_component_names[0]} and {len(source_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b u"), - source_component_name, - dep, + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[{dep}]", f"[grey]{related_url}[/grey]", f"[grey]{build_source_url}[/grey]", no_wrap=no_wrap, From f598741ce6684aa5e40a9db08948f8469dd29157 Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 09:58:01 +0100 Subject: [PATCH 4/8] minor fix of components-containing-component --- griffon/output.py | 13 +++++++------ griffon/services/core_queries.py | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/griffon/output.py b/griffon/output.py index 27c126e..2a2bd02 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -414,12 +414,6 @@ def text_output_products_contain_component( exclude_components, no_wrap=False, ): - # if -r option used we need to escape it - search_component_name = ( - re.escape(ctx.params["component_name"]) - if not ctx.obj["REGEX_NAME_SEARCH"] - else ctx.params["component_name"] - ) # handle single component if ctx.params["purl"]: @@ -431,6 +425,13 @@ def text_output_products_contain_component( ) ctx.exit() + # if -r option used we need to escape it + search_component_name = ( + re.escape(ctx.params["component_name"]) + if not ctx.obj["REGEX_NAME_SEARCH"] + else ctx.params["component_name"] + ) + # handle multiple components if "results" in output and output["count"] > 0: console.highlighter = None diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index f4db3cc..7d18891 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -521,11 +521,11 @@ def execute(self, status=None) -> List[Dict[str, Any]]: search_related_url_params["type"] = "RPM" search_related_url_params["released_components"] = "True" related_url_components_cnt = self.corgi_session.components.count( - **search_related_url_params, max_results=10000 + **search_related_url_params, ) status.update(f"found {related_url_components_cnt} related url component(s).") related_url_components = self.corgi_session.components.retrieve_list_iterator_async( - **search_related_url_params + **search_related_url_params, max_results=10000 ) for c in related_url_components: results.append(c) @@ -767,6 +767,7 @@ class components_containing_specific_component_query: "namespace", "strict_name_search", "verbose", + "regex_name_search", ] def __init__(self, params: dict): From 6449132e1f7f902f65e37cf582d7e07d6096a509 Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 11:01:54 +0100 Subject: [PATCH 5/8] minor fix component-summary --- griffon/commands/queries.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/griffon/commands/queries.py b/griffon/commands/queries.py index 38200ee..4419708 100644 --- a/griffon/commands/queries.py +++ b/griffon/commands/queries.py @@ -155,8 +155,7 @@ def get_product_summary( help="Strict search, exact match of name.", ) @click.pass_context -@progress_bar() -def retrieve_component_summary(ctx, component_name, strict_name_search, operation_status): +def retrieve_component_summary(ctx, component_name, strict_name_search): """Get Component summary.""" if not component_name: click.echo(ctx.get_help()) @@ -164,8 +163,6 @@ def retrieve_component_summary(ctx, component_name, strict_name_search, operatio cond = {} if component_name: cond["component_name"] = component_name - - operation_status.stop() ctx.invoke(get_component_summary, **cond) From 4a801ba16d3854a8f1517da784fc6acb44d91e87 Mon Sep 17 00:00:00 2001 From: jfuller Date: Sat, 20 Jan 2024 12:58:15 +0100 Subject: [PATCH 6/8] fix lint --- griffon/output.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/griffon/output.py b/griffon/output.py index 2a2bd02..0a06fd9 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -513,7 +513,7 @@ def text_output_products_contain_component( for source_component_name in source_component_names: console.print( Text(pv, style=f"{product_color} b"), - f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa no_wrap=no_wrap, ) if not (result_tree[pv][ps][cn][nvr]["upstreams"]) and not ( @@ -621,7 +621,7 @@ def text_output_products_contain_component( source_component_name = f"[bright_yellow]{source_component_names[0]} and {len(source_component_names) - 1} more[/bright_yellow]" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", no_wrap=no_wrap, ) @@ -755,7 +755,7 @@ def text_output_products_contain_component( source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, @@ -865,7 +865,7 @@ def text_output_products_contain_component( source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, @@ -974,7 +974,7 @@ def text_output_products_contain_component( source_component_name = f"{source_component_names[0]} and {len(source_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b u"), - f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", + f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", f"[grey]{build_source_url}[/grey]", From 9cd90a2626edbde41acce155ac82ba45036f72f8 Mon Sep 17 00:00:00 2001 From: jfuller Date: Sun, 21 Jan 2024 15:28:55 +0100 Subject: [PATCH 7/8] fix resolving provides with community --- griffon/services/core_queries.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 7d18891..6a799c7 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -337,7 +337,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: results = [] params = { "limit": 50, - "include_fields": "purl,type,name,related_url,namespace,software_build,nvr,release,version,arch,product_streams.product_versions,product_streams.name,product_streams.ofuri,product_streams.active,product_streams.exclude_components", # noqa + "include_fields": "purl,type,name,related_url,namespace,software_build,nvr,release,version,arch,product_streams.product_versions,product_streams.name,product_streams.ofuri,product_streams.active,product_streams.exclude_components,product_streams.relations", # noqa } component_name = ( @@ -392,7 +392,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: ) with multiprocessing.Pool() as pool: for processed_component in pool.map( - partial(process_component, self.corgi_session, search_latest_params), + partial(process_component, self.community_session, search_latest_params), latest_community_components, ): results.append(processed_component) @@ -446,7 +446,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: ) with multiprocessing.Pool() as pool: for processed_component in pool.map( - partial(process_component, self.corgi_session, search_provides_params), + partial(process_component, self.community_session, search_provides_params), latest_community_components, ): results.append(processed_component) From c889647f0a963ddcf02d5b137ff4de301569960e Mon Sep 17 00:00:00 2001 From: jfuller Date: Sun, 21 Jan 2024 15:30:21 +0100 Subject: [PATCH 8/8] minor color, fix lint --- CHANGELOG.md | 1 + griffon/output.py | 101 +++++++++++++++++++++---------- griffon/services/core_queries.py | 15 ++--- 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32576f8..f4b6700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * removed --search-redhat on service products-contain-component +* several minor output fixes ## [0.5.1] - 2024-01-19 ### Changed diff --git a/griffon/output.py b/griffon/output.py index 0a06fd9..1bb74f7 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -234,6 +234,7 @@ def generate_normalised_results( "product_version": ps["product_versions"][0]["name"], "product_stream": ps.get("name"), "product_stream_active": ps.get("active"), + "product_stream_relations": ps.get("relations"), "namespace": item.get("namespace"), "name": item.get("name"), "nvr": item.get("nvr"), @@ -388,18 +389,32 @@ def generate_affects( return affects -def process_product_color(build_type: str) -> str: - """return color used for product, currently only based on component build type""" - if build_type == "APP_INTERFACE": - return "blue" - if build_type == "CENTOS": - return "cyan" - if build_type == "PNC": - return "red" - if build_type == "KOJI": - return "yellow" - if build_type == "PYXIS": - return "green" +def process_component_color(namespace: str, build_type: str) -> str: + """return color used for component, currently only based on component build type""" + if namespace: + if namespace == "UPSTREAM": + return "u" + if build_type: + if build_type == "PYXIS": + return "green" + return "grey93" + + +def process_product_color(relations: str, build_type: str) -> str: + """return color used for product, currently only based on relations""" + if relations: + relations_types = [relation["type"] for relation in relations] + if "APP_INTERFACE" in relations_types: + return "blue" + if build_type: + if build_type == "PYXIS": + return "green" + if build_type == "PNC": + return "red" + if build_type == "KOJI": + return "yellow" + if build_type == "CENTOS": + return "yellow" return "magenta" @@ -471,7 +486,12 @@ def text_output_products_contain_component( # select the latest nvr (from sorted list) nvr = list(result_tree[pv][ps][cn].keys())[-1] product_color = process_product_color( - result_tree[pv][ps][cn][nvr]["build_type"] + result_tree[pv][ps][cn][nvr]["product_stream_relations"], + result_tree[pv][ps][cn][nvr]["build_type"], + ) + root_component_color = process_component_color( + result_tree[pv][ps][cn][nvr]["namespace"], + result_tree[pv][ps][cn][nvr]["build_type"], ) dep_name = nvr # highlight search term @@ -479,7 +499,7 @@ def text_output_products_contain_component( dep_name = highlight_search_term(search_component_name, dep_name) except re.error: pass - dep = f"[grey93]{dep_name}[/grey93]" # noqa + dep = f"[{root_component_color}]{dep_name}[/{root_component_color}]" # noqa if result_tree[pv][ps][cn][nvr]["upstreams"]: upstream_component_names = sorted( list( @@ -494,7 +514,7 @@ def text_output_products_contain_component( for upstream_component_name in upstream_component_names: console.print( Text(pv, style=f"{product_color} b"), - f"[yellow1]{upstream_component_name}[/yellow1]", + f"[pale_turquoise1]{upstream_component_name}[/pale_turquoise1]", # noqa no_wrap=no_wrap, ) if result_tree[pv][ps][cn][nvr]["sources"]: @@ -534,16 +554,20 @@ def text_output_products_contain_component( # select the latest nvr (from sorted list) nvr = list(result_tree[pv][ps][cn].keys())[-1] product_color = process_product_color( - result_tree[pv][ps][cn][nvr]["build_type"] + result_tree[pv][ps][cn][nvr]["product_stream_relations"], + result_tree[pv][ps][cn][nvr]["build_type"], + ) + root_component_color = process_component_color( + result_tree[pv][ps][cn][nvr]["namespace"], + result_tree[pv][ps][cn][nvr]["build_type"], ) # highlight search term - # dep_name = nvr dep_name = nvr try: dep_name = highlight_search_term(search_component_name, dep_name) except re.error: pass - dep = f"[grey93]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']})[/grey93]" # noqa + dep = f"[{root_component_color}]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']})[/{root_component_color}]" # noqa related_url = result_tree[pv][ps][cn][nvr].get("related_url") try: if result_tree[pv][ps][cn][nvr]["related_url"]: @@ -598,7 +622,7 @@ def text_output_products_contain_component( upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[yellow1]{upstream_component_name}[/yellow1]", + f"[pale_turquoise1]{upstream_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", no_wrap=no_wrap, ) @@ -618,7 +642,7 @@ def text_output_products_contain_component( if len(source_component_names) > 0: source_component_name = source_component_names[0] if len(source_component_names) > 1: - source_component_name = f"[bright_yellow]{source_component_names[0]} and {len(source_component_names) - 1} more[/bright_yellow]" # noqa + source_component_name = f"{source_component_names[0]} and {len(source_component_names) - 1} more]" # noqa console.print( Text(ps, style=f"{product_color} b"), f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa @@ -654,7 +678,12 @@ def text_output_products_contain_component( # select the latest nvr (from sorted list) nvr = list(result_tree[pv][ps][cn].keys())[-1] product_color = process_product_color( - result_tree[pv][ps][cn][nvr]["build_type"] + result_tree[pv][ps][cn][nvr]["product_stream_relations"], + result_tree[pv][ps][cn][nvr]["build_type"], + ) + root_component_color = process_component_color( + result_tree[pv][ps][cn][nvr]["namespace"], + result_tree[pv][ps][cn][nvr]["build_type"], ) # highlight search term dep_name = nvr @@ -665,7 +694,7 @@ def text_output_products_contain_component( ) except re.error: pass - dep = f"[grey93]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']}:{result_tree[pv][ps][cn][nvr]['arch']})[/grey93]" # noqa + dep = f"[{root_component_color}]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']}:{result_tree[pv][ps][cn][nvr]['arch']})[/{root_component_color}]" # noqa related_url = result_tree[pv][ps][cn][nvr].get("related_url") try: if result_tree[pv][ps][cn][nvr]["related_url"]: @@ -731,7 +760,7 @@ def text_output_products_contain_component( upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[yellow1]{upstream_component_name}[/yellow1]", + f"[pale_turquoise1]{upstream_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, @@ -752,7 +781,7 @@ def text_output_products_contain_component( if len(source_component_names) > 0: source_component_name = source_component_names[0] if len(source_component_names) > 1: - source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa + source_component_name = f"{source_component_names[0]} and {len(source_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa @@ -792,7 +821,12 @@ def text_output_products_contain_component( # select the latest nvr (from sorted list) nvr = list(result_tree[pv][ps][cn].keys())[-1] product_color = process_product_color( - result_tree[pv][ps][cn][nvr]["build_type"] + result_tree[pv][ps][cn][nvr]["product_stream_relations"], + result_tree[pv][ps][cn][nvr]["build_type"], + ) + root_component_color = process_component_color( + result_tree[pv][ps][cn][nvr]["namespace"], + result_tree[pv][ps][cn][nvr]["build_type"], ) # highlight search term dep_name = nvr @@ -803,7 +837,7 @@ def text_output_products_contain_component( ) except re.error: pass - dep = f"[grey93]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']}:{result_tree[pv][ps][cn][nvr]['arch']})[/grey93]" # noqa + dep = f"[{root_component_color}]{dep_name} ({result_tree[pv][ps][cn][nvr]['type']}:{result_tree[pv][ps][cn][nvr]['arch']})[/{root_component_color}]" # noqa related_url = result_tree[pv][ps][cn][nvr].get("related_url") try: if result_tree[pv][ps][cn][nvr]["related_url"]: @@ -841,7 +875,7 @@ def text_output_products_contain_component( upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), - f"[yellow1]{upstream_component_name}[/yellow1]", + f"[pale_turquoise1]{upstream_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", no_wrap=no_wrap, @@ -862,7 +896,7 @@ def text_output_products_contain_component( if len(source_component_names) > 0: source_component_name = source_component_names[0] if len(source_component_names) > 1: - source_component_name = f"[red]{source_component_names[0]} and {len(source_component_names) - 1} more[/red]" # noqa + source_component_name = f"{source_component_names[0]} and {len(source_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b"), f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa @@ -902,7 +936,12 @@ def text_output_products_contain_component( # select the latest nvr (from sorted list) nvr = list(result_tree[pv][ps][cn].keys())[-1] product_color = process_product_color( - result_tree[pv][ps][cn][nvr]["build_type"] + result_tree[pv][ps][cn][nvr]["product_stream_relations"], + result_tree[pv][ps][cn][nvr]["build_type"], + ) + root_component_color = process_component_color( + result_tree[pv][ps][cn][nvr]["namespace"], + result_tree[pv][ps][cn][nvr]["build_type"], ) # highlight search term dep_name = result_tree[pv][ps][cn][nvr]["purl"] @@ -913,7 +952,7 @@ def text_output_products_contain_component( ) except re.error: pass - dep = f"[grey93]{dep_name}[/grey93]" # noqa + dep = f"[{root_component_color}]{dep_name}[/{root_component_color}]" # noqa related_url = result_tree[pv][ps][cn][nvr].get("related_url") try: if result_tree[pv][ps][cn][nvr]["related_url"]: @@ -949,7 +988,7 @@ def text_output_products_contain_component( upstream_component_name = f"{upstream_component_names[0]} and {len(upstream_component_names) - 1} more" # noqa console.print( Text(ps, style=f"{product_color} b u"), - f"[yellow1]{upstream_component_name}[/yellow1]", + f"[pale_turquoise1]{upstream_component_name}[/pale_turquoise1]", # noqa f"[{dep}]", f"[grey]{related_url}[/grey]", f"[grey]{build_source_url}[/grey]", diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 6a799c7..58a7c4a 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -219,10 +219,10 @@ def async_retrieve_sources(self, purl): "limit": 120, "root_components": "True", "provides": purl, - "include_fields": "type,arch,nvr,purl,name,version,namespace,download_url,related_url", + "include_fields": "type,arch,nvr,purl,name,version,namespace", } try: - return list(self.components.retrieve_list_iterator_async(**params, max_results=5000)) + return list(self.components.retrieve_list_iterator_async(**params)) except Exception as e: logger.warning(f"{type(e).__name__} - problem retrieving {purl} sources.") return [] @@ -233,7 +233,7 @@ def async_retrieve_upstreams(self, purl): "limit": 120, "root_components": "True", "upstreams": purl, - "include_fields": "type,arch,nvr,purl,name,version,namespace,download_url,related_url", + "include_fields": "type,arch,nvr,purl,name,version,namespace", } try: return list(self.components.retrieve_list_iterator_async(**params, max_results=5000)) @@ -246,7 +246,7 @@ def async_retrieve_provides(self, urlparams, purl): params = { "limit": 120, "sources": purl, - "include_fields": "type,arch,nvr,purl,version,name,namespace,download_url,related_url", + "include_fields": "type,arch,nvr,purl,version,name,namespace", } if "name" in urlparams: params["name"] = urlparams["name"] @@ -267,8 +267,7 @@ def async_retrieve_provides(self, urlparams, purl): def process_component(session, urlparams, c): """perform any neccessary sub retrievals.""" - if c.sources: - c.sources = async_retrieve_sources(session, c.purl) + c.sources = async_retrieve_sources(session, c.purl) c.upstreams = async_retrieve_upstreams(session, c.purl) c.provides = async_retrieve_provides(session, urlparams, c.purl) return c @@ -418,6 +417,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: latest_components = self.corgi_session.components.retrieve_list_iterator_async( **search_provides_params, max_results=10000 ) + status.update( f"found {latest_components_cnt} latest provides child component(s)- retrieving children, sources & upstreams." # noqa ) @@ -427,7 +427,6 @@ def execute(self, status=None) -> List[Dict[str, Any]]: latest_components, ): results.append(processed_component) - if not self.no_community: status.update("searching latest community provided child component(s).") community_component_cnt = self.community_session.components.count( @@ -696,6 +695,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: ] filtered_results = [] + for result in results: is_matched = False for p in patterns: @@ -703,6 +703,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: break if type(result) == Component: m = p.match(result.name) + logger.debug(f"rh naming filtered {result.name}") if m: filtered_results.append(result) is_matched = True