Skip to content

Commit

Permalink
fix: MachineType f-string interpolation
Browse files Browse the repository at this point in the history
It looks like when things were changed over to f-strings this one line missed
the "f". I did some basic searches through the rest of the code to find other
instances of this but couldn't find any. Moved to attach_dmi since it's
derived from values there.

fixes: 5a50433 ("refactor: Use f-strings everywhere")

Signed-off-by: Chris Peterson <chris.peterson@canonical.com>
  • Loading branch information
Chris-Peterson444 authored and bdrung committed Oct 25, 2023
1 parent d20d68b commit 8ca0648
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apport/hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ def attach_dmi(report):
if value:
report[f"dmi.{f.replace('_', '.')}"] = value

# Use the hardware information to create a machine type.
if "dmi.sys.vendor" in report and "dmi.product.name" in report:
report[
"MachineType"
] = f"{report['dmi.sys.vendor']} {report['dmi.product.name']}"


def attach_hardware(report):
"""Attach a standard set of hardware-related data to the report, including:
Expand Down Expand Up @@ -266,12 +272,6 @@ def attach_hardware(report):

attach_dmi(report)

# Use the hardware information to create a machine type.
if "dmi.sys.vendor" in report and "dmi.product.name" in report:
report[
"MachineType"
] = "{report['dmi.sys.vendor']} {report['dmi.product.name']}"

if command_available("prtconf"):
report["Prtconf"] = command_output(["prtconf"])

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def mock_read_file(path: str) -> str:
"dmi.product.family": "B550 MB",
"dmi.product.name": "B550I AORUS PRO AX",
"dmi.sys.vendor": "Gigabyte Technology Co., Ltd.",
"MachineType": "Gigabyte Technology Co., Ltd. B550I AORUS PRO AX",
},
)

Expand Down

0 comments on commit 8ca0648

Please sign in to comment.