]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
doc/scripts/gen_state_diagram.py: Fix literal comparison syntax warnings
authorVarsha Rao <varao@redhat.com>
Thu, 11 Jun 2020 06:36:38 +0000 (12:06 +0530)
committerKefu Chai <kchai@redhat.com>
Mon, 1 Nov 2021 16:08:39 +0000 (00:08 +0800)
In python3.8 comparing strings using 'is' and 'is not' throws syntax warning.
Instead use equality operator.

Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 61e7bcded852e90e6249ab0f3c37ec2688537c83)

doc/scripts/gen_state_diagram.py

index a7399bb201c01849269347a7892bf0fbf8098db3..90cfb9282dcc111866f3df4aafbb89a39927a57b 100755 (executable)
@@ -23,7 +23,7 @@ def acc_lines(generator):
 def to_char(generator):
     for line in generator:
         for char in line:
-            if char is not '\n':
+            if char != '\n':
                 yield char
             else:
                 yield ' '
@@ -41,22 +41,22 @@ def remove_multiline_comments(generator):
     in_comment = False
     for char in generator:
         if in_comment:
-            if saw is "*":
-                if char is "/":
+            if saw == "*":
+                if char == "/":
                     in_comment = False
                 saw = ""
-            if char is "*":
+            if char == "*":
                 saw = "*"
             continue
-        if saw is "/":
-            if char is '*':
+        if saw == "/":
+            if char == '*':
                 in_comment = True
                 saw = ""
                 continue
             else:
                 yield saw
                 saw = ""
-        if char is '/':
+        if char == '/':
             saw = "/"
             continue
         yield char
@@ -129,7 +129,7 @@ class StateMachineRenderer(object):
             if tokens.group(2) not in self.state_contents.keys():
                 self.state_contents[tokens.group(2)] = []
             self.state_contents[tokens.group(2)].append(tokens.group(1))
-            if tokens.group(3) is not "":
+            if tokens.group(3):
                 self.machines[tokens.group(1)] = tokens.group(3)
             self.context.append((tokens.group(1), self.context_depth, ""))
             return
@@ -140,14 +140,14 @@ class StateMachineRenderer(object):
                                  line):
                 if i.group(1) not in self.edges.keys():
                     self.edges[i.group(1)] = []
-                if len(self.context) is 0:
+                if not self.context:
                     raise Exception("no context at line: " + line)
                 self.edges[i.group(1)].append((self.context[-1][0], i.group(2)))
         i = re.search("return\s+transit<\s*(\w*)\s*>()", line)
         if i is not None:
-            if len(self.context) is 0:
+            if not self.context:
                 raise Exception("no context at line: " + line)
-            if self.context[-1][2] is "":
+            if not self.context[-1][2]:
                 raise Exception("no event in context at line: " + line)
             if self.context[-1][2] not in self.edges.keys():
                 self.edges[self.context[-1][2]] = []