diff mbox series

[1/3] scripts: render_block_graph: Fix invalid escape sequence warning with python 3.12

Message ID 4d8f833ad9355cb9c64633cdbab362300f0a7b4a.1742315602.git.pkrempa@redhat.com (mailing list archive)
State New
Headers show
Series scripts: render_block_graph: Fix with new python and improve argument parsing | expand

Commit Message

Peter Krempa March 18, 2025, 4:36 p.m. UTC
From: Peter Krempa <pkrempa@redhat.com>

Trying to run 'render_block_graph' produces following warnings on
machine with python 3.12:

 $ ./scripts/render_block_graph.py cd-throttle ble.png
 ./scripts/render_block_graph.py:57: SyntaxWarning: invalid escape sequence '\l'
   '  w - Write\l'
 ./scripts/render_block_graph.py:58: SyntaxWarning: invalid escape sequence '\l'
   '  r - consistent-Read\l'
 ./scripts/render_block_graph.py:59: SyntaxWarning: invalid escape sequence '\l'
   '  u - write - Unchanged\l'
 ./scripts/render_block_graph.py:60: SyntaxWarning: invalid escape sequence '\l'

 [...]

The graphviz '\l' escape sequence is used to left-justify the line and
new python started enforcing of strings to contain only known escape
sequences. Convert the strings containing the dot language to raw.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 scripts/render_block_graph.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py
index 3e1a2e3fa7..14b2d02ec2 100755
--- a/scripts/render_block_graph.py
+++ b/scripts/render_block_graph.py
@@ -53,16 +53,16 @@  def render_block_graph(qmp, filename, format='png'):

     graph = Digraph(comment='Block Nodes Graph')
     graph.format = format
-    graph.node('permission symbols:\l'
-               '  w - Write\l'
-               '  r - consistent-Read\l'
-               '  u - write - Unchanged\l'
-               '  g - Graph-mod\l'
-               '  s - reSize\l'
-               'edge label scheme:\l'
-               '  <child type>\l'
-               '  <perm>\l'
-               '  <shared_perm>\l', shape='none')
+    graph.node(r'permission symbols:\l'
+               r'  w - Write\l'
+               r'  r - consistent-Read\l'
+               r'  u - write - Unchanged\l'
+               r'  g - Graph-mod\l'
+               r'  s - reSize\l'
+               r'edge label scheme:\l'
+               r'  <child type>\l'
+               r'  <perm>\l'
+               r'  <shared_perm>\l', shape='none')

     for n in block_graph['nodes']:
         if n['type'] == 'block-driver':
@@ -83,8 +83,8 @@  def render_block_graph(qmp, filename, format='png'):
         graph.node(str(n['id']), label, shape=shape)

     for e in block_graph['edges']:
-        label = '%s\l%s\l%s\l' % (e['name'], perm(e['perm']),
-                                  perm(e['shared-perm']))
+        label = r'%s\l%s\l%s\l' % (e['name'], perm(e['perm']),
+                                   perm(e['shared-perm']))
         graph.edge(str(e['parent']), str(e['child']), label=label)

     graph.render(filename)