Fixed code smells having rule 'Nested blocks of code should not be left empty'.

This commit is contained in:
Khushboo Vashi 2020-06-26 13:18:27 +05:30 committed by Akshay Joshi
parent 707ff450b5
commit c7a16a4bd5
9 changed files with 25 additions and 38 deletions

View File

@ -150,8 +150,7 @@ def check_and_download_vnc_browser_image(browser_name, browser_version):
elif idx == len(version_tag): elif idx == len(version_tag):
print("{0} Image is not available.".format(image_name)) print("{0} Image is not available.".format(image_name))
vnc_image_available = False vnc_image_available = False
else:
pass
return vnc_image_available return vnc_image_available

View File

@ -776,9 +776,6 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
return False return False
return True return True
elif key == 'exclude_constraint':
pass
return True return True
@staticmethod @staticmethod

View File

@ -36,9 +36,7 @@ def Themes(app):
try: try:
misc_preference = Preferences.module('misc') misc_preference = Preferences.module('misc')
theme = misc_preference.preference('theme').get() theme = misc_preference.preference('theme').get()
if theme not in all_themes: if theme in all_themes:
pass
else:
theme_css = all_themes[theme]['cssfile'] + '.css' theme_css = all_themes[theme]['cssfile'] + '.css'
except Exception: except Exception:
# Let the default theme go if exception occurs # Let the default theme go if exception occurs

View File

@ -240,25 +240,18 @@ def filename_with_file_manager_path(_file, create_file=True):
Args: Args:
file: File name returned from client file manager file: File name returned from client file manager
create_file: Set flag to False when file creation doesn't required create_file: Set flag to False when file creation doesn't required
Returns: Returns:
Filename to use for backup with full path taken from preference Filename to use for backup with full path taken from preference
""" """
# Set file manager directory from preference # Set file manager directory from preference
storage_dir = get_storage_directory() storage_dir = get_storage_directory()
if storage_dir: if storage_dir:
_file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\')) _file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\'))
elif not os.path.isabs(_file): elif not os.path.isabs(_file):
_file = os.path.join(document_dir(), _file) _file = os.path.join(document_dir(), _file)
if create_file: def short_filepath():
# Touch the file to get the short path of the file on windows.
with open(_file, 'a'):
pass
short_path = fs_short_path(_file) short_path = fs_short_path(_file)
# fs_short_path() function may return empty path on Windows # fs_short_path() function may return empty path on Windows
# if directory doesn't exists. In that case we strip the last path # if directory doesn't exists. In that case we strip the last path
# component and get the short path. # component and get the short path.
@ -266,9 +259,15 @@ def filename_with_file_manager_path(_file, create_file=True):
base_name = os.path.basename(_file) base_name = os.path.basename(_file)
dir_name = os.path.dirname(_file) dir_name = os.path.dirname(_file)
short_path = fs_short_path(dir_name) + '\\' + base_name short_path = fs_short_path(dir_name) + '\\' + base_name
return short_path return short_path
if create_file:
# Touch the file to get the short path of the file on windows.
with open(_file, 'a'):
return short_filepath()
return short_filepath()
@blueprint.route( @blueprint.route(
'/job/<int:sid>', methods=['POST'], endpoint='create_server_job' '/job/<int:sid>', methods=['POST'], endpoint='create_server_job'

View File

@ -192,7 +192,7 @@ def filename_with_file_manager_path(_file, _present=False):
if not _present: if not _present:
# Touch the file to get the short path of the file on windows. # Touch the file to get the short path of the file on windows.
with open(_file, 'a'): with open(_file, 'a'):
pass return fs_short_path(_file)
else: else:
if not os.path.isfile(_file): if not os.path.isfile(_file):
return None return None

View File

@ -345,7 +345,7 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference={}):
# ignore the keys if available. # ignore the keys if available.
if key in ignore_keys: if key in ignore_keys:
pass continue
elif key in tar_only: elif key in tar_only:
if type(target_dict[key]) is list: if type(target_dict[key]) is list:
difference[key] = {} difference[key] = {}

View File

@ -383,17 +383,15 @@ class reader(object):
self.parse_add_char(c) self.parse_add_char(c)
def _parse_in_quoted_field(self, c): def _parse_in_quoted_field(self, c):
if c == '\0': if c != '\0' and c == self.dialect.escapechar:
pass
elif c == self.dialect.escapechar:
self.state = ESCAPE_IN_QUOTED_FIELD self.state = ESCAPE_IN_QUOTED_FIELD
elif (c == self.dialect.quotechar and elif c != '\0' and (c == self.dialect.quotechar and
self.dialect.quoting != QUOTE_NONE): self.dialect.quoting != QUOTE_NONE):
if self.dialect.doublequote: if self.dialect.doublequote:
self.state = QUOTE_IN_QUOTED_FIELD self.state = QUOTE_IN_QUOTED_FIELD
else: else:
self.state = IN_FIELD self.state = IN_FIELD
else: elif c != '\0':
self.parse_add_char(c) self.parse_add_char(c)
def _parse_escape_in_quoted_field(self, c): def _parse_escape_in_quoted_field(self, c):
@ -427,11 +425,9 @@ class reader(object):
)) ))
def _parse_eat_crnl(self, c): def _parse_eat_crnl(self, c):
if c == '\n' or c == '\r': if c != '\n' and c != '\r' and c == '\0':
pass
elif c == '\0':
self.state = START_RECORD self.state = START_RECORD
else: elif c != '\n' and c != '\r':
raise Error('new-line character seen in unquoted field - do you ' raise Error('new-line character seen in unquoted field - do you '
'need to open the file in universal-newline mode?') 'need to open the file in universal-newline mode?')

View File

@ -219,7 +219,7 @@ class FileBackedSessionManager(SessionManager):
# touch the file # touch the file
with open(fname, 'wb'): with open(fname, 'wb'):
pass return ManagedSession(sid=sid)
return ManagedSession(sid=sid) return ManagedSession(sid=sid)

View File

@ -107,7 +107,5 @@ class BaseFeatureTest(BaseTestGenerator):
try: try:
os.mkdir(path) os.mkdir(path)
except OSError as e: except OSError as e:
if e.errno == errno.EEXIST: if e.errno != errno.EEXIST:
pass
else:
raise raise