sb: Fix Python literal comparison warnings

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

Signed-off-by: Anders Montonen <Anders.Montonen@iki.fi>
This commit is contained in:
Anders Montonen 2020-04-27 22:15:26 +03:00 committed by Chris Johns
parent a137ab8451
commit 0c7965c093
2 changed files with 30 additions and 30 deletions

View File

@ -338,7 +338,7 @@ class file:
raise error.general(self._name_line_msg(msg)) raise error.general(self._name_line_msg(msg))
def _label(self, name): def _label(self, name):
if name.startswith('%{') and name[-1] is '}': if name.startswith('%{') and name[-1] == '}':
return name return name
return '%{' + name.lower() + '}' return '%{' + name.lower() + '}'

View File

@ -233,7 +233,7 @@ class macros:
return [rm[5:] for rm in self.read_maps] return [rm[5:] for rm in self.read_maps]
def key_filter(self, key): def key_filter(self, key):
if key.startswith('%{') and key[-1] is '}': if key.startswith('%{') and key[-1] == '}':
key = key[2:-1] key = key[2:-1]
return key.lower() return key.lower()
@ -269,28 +269,28 @@ class macros:
print(']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % \ print(']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % \
(c, ord(c), state, token, macro, map)) (c, ord(c), state, token, macro, map))
l_remaining = l_remaining[1:] l_remaining = l_remaining[1:]
if c is '#' and not state.startswith('value'): if c == '#' and not state.startswith('value'):
break break
if c == '\n' or c == '\r': if c == '\n' or c == '\r':
if not (state is 'key' and len(token) == 0) and \ if not (state == 'key' and len(token) == 0) and \
not state.startswith('value-multiline'): not state.startswith('value-multiline'):
raise error.general('malformed macro line:%d: %s' % (lc, l)) raise error.general('malformed macro line:%d: %s' % (lc, l))
if state is 'key': if state == 'key':
if c not in string.whitespace: if c not in string.whitespace:
if c is '[': if c == '[':
state = 'map' state = 'map'
elif c is '%': elif c == '%':
state = 'directive' state = 'directive'
elif c is ':': elif c == ':':
macro += [token] macro += [token]
token = '' token = ''
state = 'attribs' state = 'attribs'
elif c is '#': elif c == '#':
break break
else: else:
token += c token += c
elif state is 'map': elif state == 'map':
if c is ']': if c == ']':
if token not in macros: if token not in macros:
macros[token] = {} macros[token] = {}
map = token map = token
@ -300,7 +300,7 @@ class macros:
token += c token += c
else: else:
raise error.general('invalid macro map:%d: %s' % (lc, l)) raise error.general('invalid macro map:%d: %s' % (lc, l))
elif state is 'directive': elif state == 'directive':
if c in string.whitespace: if c in string.whitespace:
if token == 'include': if token == 'include':
self.load(_clean(l_remaining)) self.load(_clean(l_remaining))
@ -311,7 +311,7 @@ class macros:
token += c token += c
else: else:
raise error.general('invalid macro directive:%d: %s' % (lc, l)) raise error.general('invalid macro directive:%d: %s' % (lc, l))
elif state is 'include': elif state == 'include':
if c is string.whitespace: if c is string.whitespace:
if token == 'include': if token == 'include':
state = 'include' state = 'include'
@ -319,49 +319,49 @@ class macros:
token += c token += c
else: else:
raise error.general('invalid macro directive:%d: %s' % (lc, l)) raise error.general('invalid macro directive:%d: %s' % (lc, l))
elif state is 'attribs': elif state == 'attribs':
if c not in string.whitespace: if c not in string.whitespace:
if c is ',': if c == ',':
macro += [token] macro += [token]
token = '' token = ''
if len(macro) == 3: if len(macro) == 3:
state = 'value-start' state = 'value-start'
else: else:
token += c token += c
elif state is 'value-start': elif state == 'value-start':
if c is "'": if c == "'":
state = 'value-line-start' state = 'value-line-start'
elif state is 'value-line-start': elif state == 'value-line-start':
if c is "'": if c == "'":
state = 'value-multiline-start' state = 'value-multiline-start'
else: else:
state = 'value-line' state = 'value-line'
token += c token += c
elif state is 'value-multiline-start': elif state == 'value-multiline-start':
if c is "'": if c == "'":
state = 'value-multiline' state = 'value-multiline'
else: else:
macro += [token] macro += [token]
state = 'macro' state = 'macro'
elif state is 'value-line': elif state == 'value-line':
if c is "'": if c == "'":
macro += [token] macro += [token]
state = 'macro' state = 'macro'
else: else:
token += c token += c
elif state is 'value-multiline': elif state == 'value-multiline':
if c is "'": if c == "'":
state = 'value-multiline-end' state = 'value-multiline-end'
else: else:
token += c token += c
elif state is 'value-multiline-end': elif state == 'value-multiline-end':
if c is "'": if c == "'":
state = 'value-multiline-end-end' state = 'value-multiline-end-end'
else: else:
state = 'value-multiline' state = 'value-multiline'
token += "'" + c token += "'" + c
elif state is 'value-multiline-end-end': elif state == 'value-multiline-end-end':
if c is "'": if c == "'":
macro += [token] macro += [token]
state = 'macro' state = 'macro'
else: else:
@ -369,7 +369,7 @@ class macros:
token += "''" + c token += "''" + c
else: else:
raise error.internal('bad state: %s' % (state)) raise error.internal('bad state: %s' % (state))
if state is 'macro': if state == 'macro':
macros[map][self._unicode_to_str(macro[0].lower())] = \ macros[map][self._unicode_to_str(macro[0].lower())] = \
(self._unicode_to_str(macro[1]), (self._unicode_to_str(macro[1]),
self._unicode_to_str(macro[2]), self._unicode_to_str(macro[2]),