diff --git a/tools/update_selenoid_browsers.py b/tools/update_selenoid_browsers.py index bf0c39850..02cfd99fd 100644 --- a/tools/update_selenoid_browsers.py +++ b/tools/update_selenoid_browsers.py @@ -150,8 +150,7 @@ def check_and_download_vnc_browser_image(browser_name, browser_version): elif idx == len(version_tag): print("{0} Image is not available.".format(image_name)) vnc_image_available = False - else: - pass + return vnc_image_available diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py index 445cafb2d..8f6158de0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py @@ -776,9 +776,6 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): return False return True - elif key == 'exclude_constraint': - pass - return True @staticmethod diff --git a/web/pgadmin/misc/themes/__init__.py b/web/pgadmin/misc/themes/__init__.py index 37559da16..d874ab1e6 100644 --- a/web/pgadmin/misc/themes/__init__.py +++ b/web/pgadmin/misc/themes/__init__.py @@ -36,9 +36,7 @@ def Themes(app): try: misc_preference = Preferences.module('misc') theme = misc_preference.preference('theme').get() - if theme not in all_themes: - pass - else: + if theme in all_themes: theme_css = all_themes[theme]['cssfile'] + '.css' except Exception: # Let the default theme go if exception occurs diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index ad438573a..39b546844 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -240,34 +240,33 @@ def filename_with_file_manager_path(_file, create_file=True): Args: file: File name returned from client file manager create_file: Set flag to False when file creation doesn't required - Returns: Filename to use for backup with full path taken from preference """ # Set file manager directory from preference storage_dir = get_storage_directory() - if storage_dir: _file = os.path.join(storage_dir, _file.lstrip(u'/').lstrip(u'\\')) elif not os.path.isabs(_file): _file = os.path.join(document_dir(), _file) + def short_filepath(): + short_path = fs_short_path(_file) + # fs_short_path() function may return empty path on Windows + # if directory doesn't exists. In that case we strip the last path + # component and get the short path. + if os.name == 'nt' and short_path == '': + base_name = os.path.basename(_file) + dir_name = os.path.dirname(_file) + short_path = fs_short_path(dir_name) + '\\' + base_name + return short_path + if create_file: # Touch the file to get the short path of the file on windows. with open(_file, 'a'): - pass + return short_filepath() - short_path = fs_short_path(_file) - - # fs_short_path() function may return empty path on Windows - # if directory doesn't exists. In that case we strip the last path - # component and get the short path. - if os.name == 'nt' and short_path == '': - base_name = os.path.basename(_file) - dir_name = os.path.dirname(_file) - short_path = fs_short_path(dir_name) + '\\' + base_name - - return short_path + return short_filepath() @blueprint.route( diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py index 13b70fa87..a50bf3868 100644 --- a/web/pgadmin/tools/import_export/__init__.py +++ b/web/pgadmin/tools/import_export/__init__.py @@ -192,7 +192,7 @@ def filename_with_file_manager_path(_file, _present=False): if not _present: # Touch the file to get the short path of the file on windows. with open(_file, 'a'): - pass + return fs_short_path(_file) else: if not os.path.isfile(_file): return None diff --git a/web/pgadmin/tools/schema_diff/directory_compare.py b/web/pgadmin/tools/schema_diff/directory_compare.py index 0a3738e83..853b51a47 100644 --- a/web/pgadmin/tools/schema_diff/directory_compare.py +++ b/web/pgadmin/tools/schema_diff/directory_compare.py @@ -345,7 +345,7 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference={}): # ignore the keys if available. if key in ignore_keys: - pass + continue elif key in tar_only: if type(target_dict[key]) is list: difference[key] = {} diff --git a/web/pgadmin/utils/csv.py b/web/pgadmin/utils/csv.py index 89615d449..749f14609 100644 --- a/web/pgadmin/utils/csv.py +++ b/web/pgadmin/utils/csv.py @@ -383,17 +383,15 @@ class reader(object): self.parse_add_char(c) def _parse_in_quoted_field(self, c): - if c == '\0': - pass - elif c == self.dialect.escapechar: + if c != '\0' and c == self.dialect.escapechar: self.state = ESCAPE_IN_QUOTED_FIELD - elif (c == self.dialect.quotechar and - self.dialect.quoting != QUOTE_NONE): + elif c != '\0' and (c == self.dialect.quotechar and + self.dialect.quoting != QUOTE_NONE): if self.dialect.doublequote: self.state = QUOTE_IN_QUOTED_FIELD else: self.state = IN_FIELD - else: + elif c != '\0': self.parse_add_char(c) def _parse_escape_in_quoted_field(self, c): @@ -427,11 +425,9 @@ class reader(object): )) def _parse_eat_crnl(self, c): - if c == '\n' or c == '\r': - pass - elif c == '\0': + if c != '\n' and c != '\r' and c == '\0': self.state = START_RECORD - else: + elif c != '\n' and c != '\r': raise Error('new-line character seen in unquoted field - do you ' 'need to open the file in universal-newline mode?') diff --git a/web/pgadmin/utils/session.py b/web/pgadmin/utils/session.py index 600553040..a8b94142f 100644 --- a/web/pgadmin/utils/session.py +++ b/web/pgadmin/utils/session.py @@ -219,7 +219,7 @@ class FileBackedSessionManager(SessionManager): # touch the file with open(fname, 'wb'): - pass + return ManagedSession(sid=sid) return ManagedSession(sid=sid) diff --git a/web/regression/feature_utils/base_feature_test.py b/web/regression/feature_utils/base_feature_test.py index 34a1de949..4c41474c1 100644 --- a/web/regression/feature_utils/base_feature_test.py +++ b/web/regression/feature_utils/base_feature_test.py @@ -107,7 +107,5 @@ class BaseFeatureTest(BaseTestGenerator): try: os.mkdir(path) except OSError as e: - if e.errno == errno.EEXIST: - pass - else: + if e.errno != errno.EEXIST: raise