fix(pylint): Escape backslash properly 40/41940/2
authorVratko Polak <vrpolak@cisco.com>
Wed, 27 Nov 2024 13:19:53 +0000 (14:19 +0100)
committerVratko Polak <vrpolak@cisco.com>
Wed, 27 Nov 2024 13:33:25 +0000 (13:33 +0000)
When backslach is used to escape Robot dollar or docstring asterisk,
and the backslash is in normal (not raw) Python (doc)string,
the backslash itself needs to be escaped by a second backslash.

The old code happened to work well enough,
but now it leads to a loud SyntaxWarning in console log,
so it is worth fixing faster than other pylint violations.

Change-Id: Id36fa0a393267f2cdced1229a30eaff8357c4ac4
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/python/CpuUtils.py
resources/libraries/python/autogen/Regenerator.py

index 518469b..c573417 100644 (file)
@@ -248,7 +248,7 @@ class CpuUtils:
         computing unit is physical core count.
 
         On SMT enabled DUTs, both sibling logical cores are used,
-        unless Robot variable \${smt_used} is set to False.
+        unless Robot variable \\${smt_used} is set to False.
 
         :param node: DUT node.
         :param cpu_node: Numa node number.
@@ -281,7 +281,7 @@ class CpuUtils:
             raise RuntimeError(u"NodeID is out of range!")
 
         smt_used = CpuUtils.is_smt_enabled(node[u"cpuinfo"])
-        smt_used = BuiltIn().get_variable_value("\${smt_used}", smt_used)
+        smt_used = BuiltIn().get_variable_value("\\${smt_used}", smt_used)
         cpu_list = CpuUtils.cpu_list_per_node(node, cpu_node, smt_used)
         # CPU thread sibling offset.
         sib = len(cpu_list) // CpuUtils.NR_OF_THREADS
index ce8f21d..69cacbd 100644 (file)
@@ -720,7 +720,7 @@ class Regenerator:
 
         Log-like prints are emitted to sys.stderr.
 
-        :param pattern: Glob pattern to select files. Example: \*-ndrpdr.robot
+        :param pattern: Glob pattern to select files. Example: \\*-ndrpdr.robot
         :param protocol: String determining minimal frame size. Default: "ip4"
         :type pattern: str
         :type protocol: str