From 61e7bcded852e90e6249ab0f3c37ec2688537c83 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Thu, 11 Jun 2020 12:06:38 +0530 Subject: [PATCH] doc/scripts/gen_state_diagram.py: Fix literal comparison syntax warnings In python3.8 comparing strings using 'is' and 'is not' throws syntax warning. Instead use equality operator. Signed-off-by: Varsha Rao --- doc/scripts/gen_state_diagram.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/scripts/gen_state_diagram.py b/doc/scripts/gen_state_diagram.py index a7399bb201c..90cfb9282dc 100755 --- a/doc/scripts/gen_state_diagram.py +++ b/doc/scripts/gen_state_diagram.py @@ -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]] = []