doc: extract: Use "==" instead of "is" with literals

This fixes:
    SyntaxWarning: "is" with a literal. Did you mean "=="?

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
pull/249/head
Andrej Shadura 2023-01-22 11:48:57 +01:00 committed by Ariadne Conill
parent 873e51aaae
commit cfda825f80
1 changed files with 9 additions and 9 deletions

View File

@ -70,21 +70,21 @@ def extract_comments(filename):
while True: while True:
char = source_file.read(1) char = source_file.read(1)
if not char: if not char:
if state is 3 or state is 4: if state == 3 or state == 4:
raise UnterminatedCommentError() raise UnterminatedCommentError()
if state is 2: if state == 2:
# Was in single line comment. Create comment. # Was in single line comment. Create comment.
comment = Comment(current_comment, line_counter, False) comment = Comment(current_comment, line_counter, False)
comments.append(comment) comments.append(comment)
return comments return comments
if state is 0: if state == 0:
# Waiting for comment start character or beginning of # Waiting for comment start character or beginning of
# string. # string.
if char == '/': if char == '/':
state = 1 state = 1
elif char == '"': elif char == '"':
state = 5 state = 5
elif state is 1: elif state == 1:
# Found comment start character, classify next character and # Found comment start character, classify next character and
# determine if single or multiline comment. # determine if single or multiline comment.
if char == '/': if char == '/':
@ -94,7 +94,7 @@ def extract_comments(filename):
state = 3 state = 3
else: else:
state = 0 state = 0
elif state is 2: elif state == 2:
# In single line comment, read characters until EOL. # In single line comment, read characters until EOL.
if char == '\n': if char == '\n':
comment = Comment(current_comment, line_counter, False) comment = Comment(current_comment, line_counter, False)
@ -103,14 +103,14 @@ def extract_comments(filename):
state = 0 state = 0
else: else:
current_comment += char current_comment += char
elif state is 3: elif state == 3:
# In multi-line comment, add characters until '*' # In multi-line comment, add characters until '*'
# encountered. # encountered.
if char == '*': if char == '*':
state = 4 state = 4
else: else:
current_comment += char current_comment += char
elif state is 4: elif state == 4:
# In multi-line comment with asterisk found. Determine if # In multi-line comment with asterisk found. Determine if
# comment is ending. # comment is ending.
if char == '/': if char == '/':
@ -125,13 +125,13 @@ def extract_comments(filename):
if char != '*': if char != '*':
current_comment += char current_comment += char
state = 3 state = 3
elif state is 5: elif state == 5:
# In string literal, expect literal end or escape char. # In string literal, expect literal end or escape char.
if char == '"': if char == '"':
state = 0 state = 0
elif char == '\\': elif char == '\\':
state = 6 state = 6
elif state is 6: elif state == 6:
# In string literal, escaping current char. # In string literal, escaping current char.
state = 5 state = 5
if char == '\n': if char == '\n':