Skip to content

Commit

Permalink
tplgtool2.py: Use ifelse to avoid dependency on Python 3.10
Browse files Browse the repository at this point in the history
The match statement is newly introduced in Python 3.10, change
it to ifelse to avoid SyntaxError with earlier Python version.

Signed-off-by: Yong Zhi <[email protected]>
  • Loading branch information
yongzhi1 authored and marc-hb committed May 8, 2023
1 parent 1146940 commit c5f6870
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/tplgtool2.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,14 @@ def node_name_in_graph(self, node: Container) -> str:
"""
return self._node_name_in_graph_from_name(node["widget"]["name"])

# pylint: disable=R0201
def node_sublabel(self, widget: Container) -> str:
match widget["widget"]["id"]:
case 'PGA':
sublabel = f'<BR ALIGN="CENTER"/><SUB>PGA: {widget["kcontrols"][0]["hdr"]["name"]}</SUB>'
case 'AIF_IN' | 'AIF_OUT' | 'DAI_IN' | 'DAI_OUT':
sublabel = f'<BR ALIGN="CENTER"/><SUB>{widget["widget"]["id"]}: {widget["widget"]["sname"]}</SUB>'
case _:
sublabel = ""
if widget["widget"]["id"] == 'PGA':
sublabel = f'<BR ALIGN="CENTER"/><SUB>PGA: {widget["kcontrols"][0]["hdr"]["name"]}</SUB>'
elif widget["widget"]["id"] in ['AIF_IN' , 'AIF_OUT' , 'DAI_IN' , 'DAI_OUT']:
sublabel = f'<BR ALIGN="CENTER"/><SUB>{widget["widget"]["id"]}: {widget["widget"]["sname"]}</SUB>'
else:
sublabel = ""
return sublabel

def _display_node_attrs(self, name: str, widget: Container):
Expand Down

0 comments on commit c5f6870

Please sign in to comment.