Lint: E711 comparison to None should be 'if cond is not None:'

This commit is contained in:
Joshua Boniface 2020-11-06 19:37:13 -05:00
parent ce01b41d81
commit 57c51d3234
3 changed files with 12 additions and 12 deletions

View File

@ -710,11 +710,11 @@ def vm_modify(domain, cfgfile, editor, restart):
click.echo('') click.echo('')
diff = list(difflib.unified_diff(current_vm_cfgfile.split('\n'), new_vm_cfgfile.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) diff = list(difflib.unified_diff(current_vm_cfgfile.split('\n'), new_vm_cfgfile.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm=''))
for line in diff: for line in diff:
if re.match('^\+', line) != None: if re.match('^\+', line) is not None:
click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
elif re.match('^\-', line) != None: elif re.match('^\-', line) is not None:
click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) click.echo(colorama.Fore.RED + line + colorama.Fore.RESET)
elif re.match('^[^]', line) != None: elif re.match('^[^]', line) is not None:
click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
else: else:
click.echo(line) click.echo(line)
@ -2917,11 +2917,11 @@ def provisioner_userdata_modify(name, filename, editor):
click.echo('') click.echo('')
diff = list(difflib.unified_diff(current_userdata.split('\n'), new_userdata.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) diff = list(difflib.unified_diff(current_userdata.split('\n'), new_userdata.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm=''))
for line in diff: for line in diff:
if re.match('^\+', line) != None: if re.match('^\+', line) is not None:
click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
elif re.match('^\-', line) != None: elif re.match('^\-', line) is not None:
click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) click.echo(colorama.Fore.RED + line + colorama.Fore.RESET)
elif re.match('^[^]', line) != None: elif re.match('^[^]', line) is not None:
click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
else: else:
click.echo(line) click.echo(line)
@ -3096,11 +3096,11 @@ def provisioner_script_modify(name, filename, editor):
click.echo('') click.echo('')
diff = list(difflib.unified_diff(current_script.split('\n'), new_script.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) diff = list(difflib.unified_diff(current_script.split('\n'), new_script.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm=''))
for line in diff: for line in diff:
if re.match('^\+', line) != None: if re.match('^\+', line) is not None:
click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
elif re.match('^\-', line) != None: elif re.match('^\-', line) is not None:
click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) click.echo(colorama.Fore.RED + line + colorama.Fore.RESET)
elif re.match('^[^]', line) != None: elif re.match('^[^]', line) is not None:
click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
else: else:
click.echo(line) click.echo(line)

View File

@ -1337,7 +1337,7 @@ def collect_vm_stats(queue):
memprov += instance.getmemory() memprov += instance.getmemory()
vcpualloc += instance.getvcpus() vcpualloc += instance.getvcpus()
if instance.getstate() == 'start' and instance.getnode() == this_node.name: if instance.getstate() == 'start' and instance.getnode() == this_node.name:
if instance.getdom() != None: if instance.getdom() is not None:
try: try:
if instance.getdom().state()[0] != libvirt.VIR_DOMAIN_RUNNING: if instance.getdom().state()[0] != libvirt.VIR_DOMAIN_RUNNING:
raise raise

View File

@ -638,7 +638,7 @@ class VMInstance(object):
# Check the current state of the VM # Check the current state of the VM
try: try:
if self.dom != None: if self.dom is not None:
running, reason = self.dom.state() running, reason = self.dom.state()
else: else:
raise raise
@ -766,7 +766,7 @@ class VMInstance(object):
# After everything # After everything
finally: finally:
# Close the libvirt connection # Close the libvirt connection
if lv_conn != None: if lv_conn is not None:
lv_conn.close() lv_conn.close()
# Return the dom object (or None) # Return the dom object (or None)