Verified Commit ff84dfea authored by Danh Doan's avatar Danh Doan Committed by David Heidelberg

fix python 3.8 warning (#148)

Fix SyntaxWarning: "is" with a literal. Did you mean "=="?
This is on python 3.8.

v2:
  Fixed an inverted logic in the original patch.
  Amended-by: Sebastian@SSpaeth.de

Fixes: World/PasswordSafe#148
Closes: World/PasswordSafe!82
Closes: World/PasswordSafe!84
parent c1bd5bb8
Pipeline #216571 passed with stage
in 17 minutes and 23 seconds
......@@ -75,7 +75,7 @@ class EntryPage:
scrolled_page.name_property_value_entry.connect("changed", self.on_property_value_entry_changed, "name")
properties_list_box.add(scrolled_page.name_property_row)
scrolled_page.name_property_value_entry.grab_focus()
elif scrolled_page.name_property_row is not "":
elif scrolled_page.name_property_row:
value = self.unlocked_database.database_manager.get_entry_name_from_entry_uuid(entry_uuid)
if self.unlocked_database.database_manager.has_entry_name(entry_uuid) is True:
scrolled_page.name_property_value_entry.set_text(value)
......@@ -99,7 +99,7 @@ class EntryPage:
scrolled_page.username_property_value_entry.connect("icon-press", self.unlocked_database.on_copy_secondary_button_clicked)
scrolled_page.username_property_value_entry.connect("changed", self.on_property_value_entry_changed, "username")
properties_list_box.add(scrolled_page.username_property_row)
elif scrolled_page.username_property_row is not "":
elif scrolled_page.username_property_row:
value = self.unlocked_database.database_manager.get_entry_username_from_entry_uuid(entry_uuid)
if self.unlocked_database.database_manager.has_entry_username(entry_uuid) is True:
scrolled_page.username_property_value_entry.set_text(value)
......@@ -142,7 +142,7 @@ class EntryPage:
self.change_password_entry_visibility(scrolled_page.password_property_value_entry, scrolled_page.show_password_button)
properties_list_box.add(scrolled_page.password_property_row)
elif scrolled_page.password_property_row is not "":
elif scrolled_page.password_property_row:
value = self.unlocked_database.database_manager.get_entry_password_from_entry_uuid(entry_uuid)
if self.unlocked_database.database_manager.has_entry_password(entry_uuid) is True:
scrolled_page.password_property_value_entry.set_text(value)
......@@ -167,7 +167,7 @@ class EntryPage:
scrolled_page.url_property_value_entry.connect("icon-press", self.on_link_secondary_button_clicked)
scrolled_page.url_property_value_entry.connect("changed", self.on_property_value_entry_changed, "url")
properties_list_box.add(scrolled_page.url_property_row)
elif scrolled_page.url_property_row is not "":
elif scrolled_page.url_property_row:
value = self.unlocked_database.database_manager.get_entry_url_from_entry_uuid(entry_uuid)
if self.unlocked_database.database_manager.has_entry_url(entry_uuid) is True:
scrolled_page.url_property_value_entry.set_text(value)
......@@ -194,7 +194,7 @@ class EntryPage:
buffer.set_text("")
buffer.connect("changed", self.on_property_value_entry_changed, "notes")
properties_list_box.add(scrolled_page.notes_property_row)
elif scrolled_page.notes_property_row is not "":
elif scrolled_page.notes_property_row:
value = self.unlocked_database.database_manager.get_entry_notes_from_entry_uuid(entry_uuid)
buffer = scrolled_page.notes_property_value_entry.get_buffer()
if self.unlocked_database.database_manager.has_entry_notes(entry_uuid) is True:
......
......@@ -58,14 +58,14 @@ class EntryRow(Gtk.ListBoxRow):
entry_icon.set_from_icon_name(passwordsafe.icon.get_icon("0"), 20)
# Title/Name
if self.database_manager.has_entry_name(self.entry_uuid) is True and self.label is not "":
if self.database_manager.has_entry_name(self.entry_uuid) and self.label:
entry_name_label.set_text(self.label)
else:
entry_name_label.set_markup("<span font-style=\"italic\">" + _("Title not specified") + "</span>")
# Subtitle
subtitle = self.database_manager.get_entry_username_from_entry_uuid(self.entry_uuid)
if (self.database_manager.has_entry_username(self.entry_uuid) is True and subtitle is not ""):
if (self.database_manager.has_entry_username(self.entry_uuid) and subtitle):
username = self.database_manager.get_entry_username_from_entry_uuid(self.entry_uuid)
if username.startswith("{REF:U"):
entry_subtitle_label.set_text(self.database_manager.get_entry_username_from_entry_uuid(u.UUID(self.unlocked_database.reference_to_hex_uuid(username))))
......
......@@ -31,7 +31,7 @@ class GroupRow(Gtk.ListBoxRow):
group_name_label = builder.get_object("group_name_label")
if self.label is not None and self.label is not "":
if self.label:
group_name_label.set_text(self.label)
else:
group_name_label.set_markup("<span font-style=\"italic\">" + _("No group title specified") + "</span>")
......
......@@ -182,10 +182,10 @@ class MainWindow(Gtk.ApplicationWindow):
def first_start_screen(self):
filepath = Gio.File.new_for_uri(passwordsafe.config_manager.get_last_opened_database()).get_path()
if len(self.get_application().file_list) is not 0:
if self.get_application().file_list:
for g_file in self.get_application().file_list:
self.start_database_opening_routine(g_file.get_basename(), g_file.get_path())
elif passwordsafe.config_manager.get_first_start_screen() is True and filepath is not "" and filepath is not None and os.path.exists(filepath) is True:
elif passwordsafe.config_manager.get_first_start_screen() and filepath and os.path.exists(filepath):
self.logging_manager.debug("Found last opened database (" + filepath + ")")
tab_title = ntpath.basename(filepath)
self.start_database_opening_routine(tab_title, filepath)
......@@ -201,7 +201,7 @@ class MainWindow(Gtk.ApplicationWindow):
pix = Pixbuf.new_from_resource_at_scale("/org/gnome/PasswordSafe/images/welcome.png", 256, 256, True)
if len(passwordsafe.config_manager.get_last_opened_list()) is not 0:
if passwordsafe.config_manager.get_last_opened_list():
last_opened_list_box = builder.get_object("last_opened_list_box")
last_opened_list_box.connect("row-activated", self.on_last_opened_list_box_activated)
......@@ -467,7 +467,7 @@ class MainWindow(Gtk.ApplicationWindow):
else:
self.container.set_show_tabs(False)
if self.container.get_n_pages() is 0:
if not self.container.get_n_pages():
self.container.hide()
self.remove(self.container)
......
......@@ -117,7 +117,7 @@ class NotesDialog():
)
start = notes_buffer.get_start_iter()
if entry.get_text() is not "":
if entry.get_text():
self.do_search(notes_buffer, entry.get_text(), start)
def on_search_stopped(self, entry):
......
......@@ -22,11 +22,11 @@ class ResponsiveUI:
def action_bar(self):
scrolled_page = self.unlocked_database.stack.get_child_by_name(self.unlocked_database.database_manager.get_group_uuid_from_group_object(self.unlocked_database.current_group).urn)
if self.unlocked_database.window.mobile_width is True:
if len(self.unlocked_database.pathbar.viewport.get_children()) is not 0:
if self.unlocked_database.pathbar.viewport.get_children():
self.unlocked_database.pathbar.viewport.remove(self.unlocked_database.pathbar)
self.unlocked_database.pathbar.pathbar_box.hide()
if len(self.unlocked_database.action_bar_box.get_children()) is 0:
if self.unlocked_database.action_bar_box.get_children():
self.unlocked_database.action_bar_box.add(self.unlocked_database.pathbar)
if scrolled_page.edit_page is False and self.unlocked_database.stack.get_visible_child() is not self.unlocked_database.stack.get_child_by_name("search"):
......@@ -36,17 +36,17 @@ class ResponsiveUI:
else:
self.unlocked_database.revealer.set_reveal_child(False)
if len(self.unlocked_database.action_bar_box.get_children()) is not 0:
if self.unlocked_database.action_bar_box.get_children():
self.unlocked_database.action_bar_box.remove(self.unlocked_database.pathbar)
if len(self.unlocked_database.pathbar.viewport.get_children()) is 0:
if self.unlocked_database.pathbar.viewport.get_children():
self.unlocked_database.pathbar.viewport.add(self.unlocked_database.pathbar)
self.unlocked_database.pathbar.pathbar_box.show()
def headerbar_title(self):
scrolled_page = self.unlocked_database.stack.get_child_by_name(self.unlocked_database.database_manager.get_group_uuid_from_group_object(self.unlocked_database.current_group).urn)
if self.unlocked_database.window.mobile_width is True and self.unlocked_database.selection_ui.selection_mode_active is False:
if len(self.unlocked_database.builder.get_object("title_box").get_children()) is not 0:
if self.unlocked_database.builder.get_object("title_box").get_children():
return
filename_label = self.unlocked_database.builder.get_object("filename_label")
......@@ -60,7 +60,7 @@ class ResponsiveUI:
self.unlocked_database.builder.get_object("title_box").add(filename_label)
else:
if len(self.unlocked_database.builder.get_object("title_box").get_children()) is 0:
if self.unlocked_database.builder.get_object("title_box").get_children():
return
self.unlocked_database.builder.get_object("title_box").remove(self.unlocked_database.builder.get_object("filename_label"))
......
......@@ -97,12 +97,12 @@ class Search:
scrolled_page.add(viewport)
scrolled_page.show_all()
self.unlocked_database.stack.add_named(scrolled_page, "search")
if len(self.search_list_box.get_children()) is 0:
if self.search_list_box.get_children():
self.search_list_box.show()
else:
info_search_overlay = self.unlocked_database.builder.get_object("info_search_overlay")
self.unlocked_database.search_overlay.add_overlay(info_search_overlay)
self.search_list_box.hide()
else:
self.search_list_box.show()
self.unlocked_database.stack.set_visible_child(self.unlocked_database.stack.get_child_by_name("search"))
......@@ -125,7 +125,7 @@ class Search:
GLib.idle_add(self.search_overlay_creation, widget, result_list, empty_search_overlay, info_search_overlay)
def search_overlay_creation(self, widget, result_list, empty_search_overlay, info_search_overlay):
if widget.get_text() is not "":
if widget.get_text():
if empty_search_overlay in self.unlocked_database.search_overlay:
self.unlocked_database.search_overlay.remove(empty_search_overlay)
......@@ -189,11 +189,11 @@ class Search:
self.search_list_box.show()
if len(self.search_list_box.get_children()) is 0:
if self.search_list_box.get_children():
self.search_list_box.show()
else:
self.unlocked_database.search_overlay.add_overlay(empty_search_overlay)
self.search_list_box.hide()
else:
self.search_list_box.show()
#
# Events
......@@ -253,21 +253,21 @@ class Search:
def on_headerbar_search_entry_enter_pressed(self, widget):
self.unlocked_database.start_database_lock_timer()
if widget.get_text() is not "":
if widget.get_text():
uuid = NotImplemented
first_row = NotImplemented
if len(self.search_list_box.get_children()) != 0:
selected_row = self.search_list_box.get_selected_row()
if selected_row is None:
if self.search_list_box.get_children()[0].type is "GroupRow":
if self.search_list_box.get_children()[0].type == "GroupRow":
uuid = self.search_list_box.get_children()[0].get_uuid()
first_row = self.unlocked_database.database_manager.get_group_object_from_uuid(uuid)
else:
uuid = self.search_list_box.get_children()[0].get_uuid()
first_row = self.unlocked_database.database_manager.get_entry_object_from_uuid(uuid)
else:
if selected_row.type is "GroupRow":
if selected_row.type == "GroupRow":
uuid = selected_row.get_uuid()
first_row = self.unlocked_database.database_manager.get_group_object_from_uuid(uuid)
else:
......
......@@ -263,7 +263,7 @@ class SelectionUI:
list_box = column.get_children()[0]
for row in list_box:
if selection_type is "all":
if selection_type == "all":
row.selection_checkbox.set_active(True)
else:
row.selection_checkbox.set_active(False)
......
......@@ -57,7 +57,7 @@ class SettingsDialog():
settings_clear_button = self.builder.get_object("settings_clear_button")
settings_clear_button.connect("clicked", self.on_settings_clear_recents_clicked)
if len(passwordsafe.config_manager.get_last_opened_list()) is 0:
if passwordsafe.config_manager.get_last_opened_list():
settings_clear_button.set_sensitive(False)
settings_remember_switch = self.builder.get_object("settings_remember_switch")
......@@ -108,7 +108,7 @@ class SettingsDialog():
def on_settings_clear_recents_clicked(self, widget):
passwordsafe.config_manager.set_last_opened_list([])
if self.window.container is not NotImplemented and self.window.container.get_n_pages() is 0 or self.window.container is NotImplemented:
if self.window.container is NotImplemented or not self.window.container.get_n_pages():
builder = Gtk.Builder()
builder.add_from_resource(
"/org/gnome/PasswordSafe/main_window.ui")
......
......@@ -489,7 +489,7 @@ class UnlockDatabase:
self.window.logging_manager.debug("Could not open database, wrong password")
else:
if composite_unlock_entry.get_text() is not "" and self.composite_keyfile_path is not NotImplemented:
if composite_unlock_entry.get_text() and self.composite_keyfile_path is not NotImplemented:
composite_unlock_select_button = self.builder.get_object("composite_unlock_select_button")
composite_unlock_button = self.builder.get_object("composite_unlock_button")
composite_unlock_button_image = composite_unlock_button.get_children()[0]
......
......@@ -432,14 +432,14 @@ class UnlockedDatabase:
for entry_row in sorted_list:
list_box.add(entry_row)
if len(list_box.get_children()) is 0:
if list_box.get_children():
list_box.show()
else:
builder = Gtk.Builder()
builder.add_from_resource("/org/gnome/PasswordSafe/unlocked_database.ui")
empty_group_overlay = builder.get_object("empty_group_overlay")
overlay.add_overlay(empty_group_overlay)
list_box.hide()
else:
list_box.show()
def rebuild_all_pages(self):
for page in self.stack.get_children():
......@@ -849,7 +849,7 @@ class UnlockedDatabase:
def clear_clipboard(self):
clear_clipboard_time = passwordsafe.config_manager.get_clear_clipboard()
if clear_clipboard_time is not 0:
if clear_clipboard_time:
self.clipboard.clear()
def start_database_lock_timer(self):
......@@ -859,7 +859,7 @@ class UnlockedDatabase:
if self.database_lock_timer is not NotImplemented:
self.database_lock_timer.cancel()
timeout = passwordsafe.config_manager.get_database_lock_timeout() * 60
if timeout is not 0:
if timeout:
self.database_lock_timer = Timer(timeout, GLib.idle_add, args=[self.lock_timeout_database])
self.database_lock_timer.start()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment