Imrpoved logging
This commit is contained in:
parent
c439ad41aa
commit
e99a57b074
@ -227,7 +227,7 @@ class WorkspaceGroup:
|
|||||||
return output.name
|
return output.name
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_match_level(self, output: OutputReply) -> OutputMatch:
|
def get_match_level(self, output: OutputReply, context: str = "") -> OutputMatch:
|
||||||
"""Get the match level score for the output."""
|
"""Get the match level score for the output."""
|
||||||
if self.make and self.model and self.serial:
|
if self.make and self.model and self.serial:
|
||||||
if (
|
if (
|
||||||
@ -236,13 +236,13 @@ class WorkspaceGroup:
|
|||||||
and output.serial == self.serial
|
and output.serial == self.serial
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
f"Match level: ID_MATCH for {output.name} on group {self.name}",
|
f"Context {context}: ID_MATCH for {output.name} on group {self.name}",
|
||||||
flush=True,
|
flush=True,
|
||||||
)
|
)
|
||||||
return OutputMatch.ID_MATCH
|
return OutputMatch.ID_MATCH
|
||||||
if output.name in self.output_names:
|
if output.name in self.output_names:
|
||||||
print(
|
print(
|
||||||
f"Match level: NAME_MATCH for {output.name} on group {self.name}",
|
f"Context {context}: NAME_MATCH for {output.name} on group {self.name}",
|
||||||
flush=True,
|
flush=True,
|
||||||
)
|
)
|
||||||
return OutputMatch.NAME_MATCH
|
return OutputMatch.NAME_MATCH
|
||||||
@ -294,10 +294,16 @@ class WorkspaceContext:
|
|||||||
result = 0
|
result = 0
|
||||||
for group in self.groups:
|
for group in self.groups:
|
||||||
group_result = max(
|
group_result = max(
|
||||||
[group.get_match_level(output).value for output in outputs]
|
[
|
||||||
|
group.get_match_level(output, context=self.name).value
|
||||||
|
for output in outputs
|
||||||
|
]
|
||||||
)
|
)
|
||||||
if group_result == 0:
|
if group_result == 0:
|
||||||
print(f"Context {self.name}: failed to match group {group.name}")
|
print(
|
||||||
|
f"Context {self.name}: failed to match group {group.name}",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
return 0
|
return 0
|
||||||
result += group_result
|
result += group_result
|
||||||
return result
|
return result
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user