Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #191 from RedHatProductSecurity/minor
Browse files Browse the repository at this point in the history
fix summary count
  • Loading branch information
JimFuller-RedHat authored May 24, 2023
2 parents 95d21fc + 06bd51b commit 8a4668a
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 14 deletions.
122 changes: 109 additions & 13 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,15 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
]
)
)
if upstream_component_names:
if len(upstream_component_names) > 0:
upstream_component_name = (
f"[cyan]{upstream_component_names[0]}[/cyan]"
)
if len(upstream_component_names) > 1:
upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa
console.print(
Text(ps, style="magenta b u"),
f"[cyan]{upstream_component_names[0]} (and {len(upstream_component_names)} more)[/cyan]", # noqa
upstream_component_name,
dep,
f"([grey]{related_url}[/grey])",
no_wrap=False,
Expand All @@ -343,17 +348,22 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
]
)
)
if source_component_names:
if len(source_component_names) > 0:
source_component_name = (
f"[red]{source_component_names[0]}[/red]"
)
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="magenta b u"),
f"[light_blue]{source_component_names[0]} (and {len(source_component_names)} more)[/light_blue]", # noqa
source_component_name,
dep,
f"([grey]{related_url}[/grey])",
no_wrap=False,
)
if (
not result_tree[pv][ps][cn][nvr]["upstreams"]
and not result_tree[pv][ps][cn][nvr]["sources"]
len(result_tree[pv][ps][cn][nvr]["upstreams"]) == 0
and len(result_tree[pv][ps][cn][nvr]["sources"]) == 0
):
console.print(
Text(ps, style="magenta b u"),
Expand Down Expand Up @@ -395,12 +405,18 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
]
)
)
if upstream_component_names:
if len(upstream_component_names) > 0:
upstream_component_name = (
f"[cyan]{upstream_component_names[0]}[/cyan]"
)
if len(upstream_component_names) > 1:
upstream_component_name = f"[cyan]{upstream_component_names[0]} and {len(upstream_component_names) - 1} more[/cyan]" # noqa
console.print(
Text(ps, style="magenta b u"),
f"[cyan]{upstream_component_names[0]} (and {len(upstream_component_names)} more)[/cyan]", # noqa
upstream_component_name,
dep,
f"([grey]{related_url}[/grey])",
f"([grey]{build_source_url}[/grey])",
no_wrap=False,
)
source_component_names = list(
Expand All @@ -413,12 +429,92 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
]
)
)
if source_component_names:
if len(source_component_names) > 0:
source_component_name = (
f"[red]{source_component_names[0]}[/red]"
)
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="magenta b u"),
f"[light_blue]{source_component_names[0]} (and {len(source_component_names)} more)[/light_blue]", # noqa
source_component_name,
dep,
f"([grey]{related_url}[/grey])",
f"([grey]{build_source_url}[/grey])",
no_wrap=False,
)
if (
len(result_tree[pv][ps][cn][nvr]["upstreams"]) == 0
and len(result_tree[pv][ps][cn][nvr]["sources"]) == 0
):
console.print(
Text(ps, style="magenta b u"),
dep,
f"([grey]{related_url}[/grey])",
no_wrap=False,
)
if (
ctx.obj["VERBOSE"] == 3
): # product_stream X nvr (full source/upstreams) x related_url x build_source_url
for pv in result_tree.keys():
for ps in result_tree[pv].keys():
for cn in result_tree[pv][ps].keys():
if not any([match in cn for match in exclude_components]):
for nvr in result_tree[pv][ps][cn].keys():
dep_name = re.sub(
search_component_name,
f"[b]{search_component_name}[/b]",
nvr,
)
dep = f"[grey93]{dep_name}[/grey93]"
related_url = ""
if result_tree[pv][ps][cn][nvr]["related_url"]:
related_url = re.sub(
search_component_name,
f"[b]{search_component_name}[/b]",
result_tree[pv][ps][cn][nvr]["related_url"],
)
build_source_url = ""
if result_tree[pv][ps][cn][nvr]["build_source_url"]:
build_source_url = result_tree[pv][ps][cn][nvr][
"build_source_url"
]
upstream_component_names = list(
set(
[
source["name"]
for source in result_tree[pv][ps][cn][nvr][
"upstreams"
]
]
)
)
for upstream_name in upstream_component_names:
console.print(
Text(ps, style="magenta b u"),
f"[cyan]{upstream_name}[/cyan]",
dep,
f"([grey]{related_url}[/grey])",
f"([grey]{build_source_url}[/grey])",
no_wrap=False,
)
source_component_names = list(
set(
[
source["name"]
for source in result_tree[pv][ps][cn][nvr][
"sources"
]
]
)
)
for source_name in source_component_names:
console.print(
Text(ps, style="magenta b u"),
f"[light_blue]{source_name}[/light_blue]",
dep,
f"([grey]{related_url}[/grey])",
f"([grey]{build_source_url}[/grey])",
no_wrap=False,
)
if (
Expand All @@ -433,7 +529,7 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
no_wrap=False,
)
if (
ctx.obj["VERBOSE"] > 2
ctx.obj["VERBOSE"] > 3
): # product_stream X nvr (full source/upstreams) x related_url x build_source_url
for pv in result_tree.keys():
for ps in result_tree[pv].keys():
Expand Down Expand Up @@ -461,7 +557,7 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
upstream_component_names = list(
set(
[
source["name"]
source["nvr"]
for source in result_tree[pv][ps][cn][nvr][
"upstreams"
]
Expand All @@ -480,7 +576,7 @@ def text_output_products_contain_component(ctx, output, exclude_products, exclud
source_component_names = list(
set(
[
source["name"]
source["nvr"]
for source in result_tree[pv][ps][cn][nvr][
"sources"
]
Expand Down
2 changes: 1 addition & 1 deletion griffon/services/core_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __init__(self, params: dict) -> None:
def execute(self) -> List[Dict[str, Any]]:
results = []
params = {
"include_fields": "link,purl,type,name,related_url,namespace,software_build,nvr,sources.purl,sources.name,upstreams.purl,upstreams.name,release,version,arch,product_streams.product_versions,product_streams.name,product_streams.ofuri", # noqa
"include_fields": "link,purl,type,name,related_url,namespace,software_build,nvr,sources.nvr,sources.purl,sources.name,sources.download_url,sources.related_url,upstreams.nvr,upstreams.purl,upstreams.name,upstreams.download_url,upstreams.related_url,release,version,arch,product_streams.product_versions,product_streams.name,product_streams.ofuri", # noqa
}

if self.search_latest:
Expand Down

0 comments on commit 8a4668a

Please sign in to comment.