[Xfce4-commits] [apps/catfish] 01/02: Apply numerous pylint fixes
noreply at xfce.org
noreply at xfce.org
Wed Jan 1 18:43:58 CET 2020
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/catfish.
commit acbacb0bc04c74838c73162eebe16cbe55427fcd
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Wed Jan 1 12:43:00 2020 -0500
Apply numerous pylint fixes
---
bin/catfish | 8 +-
catfish/CatfishPrefsDialog.py | 12 ++-
catfish/CatfishSearchEngine.py | 86 ++++++++++----------
catfish/CatfishWindow.py | 177 ++++++++++++++++++++---------------------
catfish/__init__.py | 7 +-
catfish_lib/Builder.py | 4 +-
catfish_lib/CatfishSettings.py | 15 ++--
catfish_lib/SudoDialog.py | 19 ++---
catfish_lib/Thumbnailer.py | 10 ++-
catfish_lib/Window.py | 22 ++---
catfish_lib/__init__.py | 2 +-
catfish_lib/catfishconfig.py | 2 +-
catfish_lib/helpers.py | 28 +------
po/catfish.pot | 116 +++++++++++++--------------
setup.py | 58 +++++++-------
15 files changed, 279 insertions(+), 287 deletions(-)
diff --git a/bin/catfish b/bin/catfish
index a226631..5f06a6a 100755
--- a/bin/catfish
+++ b/bin/catfish
@@ -16,18 +16,20 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+import os
+import sys
+
+
import locale
locale.textdomain('catfish')
-import sys
-import os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Check GTK Version, minimum required is 3.10
-if Gtk.check_version(3,10,0):
+if Gtk.check_version(3, 10, 0):
print("Gtk version too old, version 3.10 required.")
sys.exit(1)
diff --git a/catfish/CatfishPrefsDialog.py b/catfish/CatfishPrefsDialog.py
index dd2df13..ef2d6ae 100644
--- a/catfish/CatfishPrefsDialog.py
+++ b/catfish/CatfishPrefsDialog.py
@@ -16,6 +16,10 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+# pylint: disable=C0114
+# pylint: disable=C0116
+# pylint: disable=C0413
+
import logging
import gi
@@ -24,7 +28,7 @@ from gi.repository import Gtk
from catfish_lib.PrefsDialog import PrefsDialog
-logger = logging.getLogger('catfish')
+LOGGER = logging.getLogger('catfish')
# See catfish_lib.PrefsDialog.py for more details about how this class works.
@@ -93,14 +97,14 @@ class CatfishPrefsDialog(PrefsDialog):
self.settings.set_setting("close-after-select", False)
self.changed_properties.append("close-after-select")
- def on_add_directory_clicked(self, widget):
+ def on_add_directory_clicked(self, widget): # pylint: disable=W0613
dlg = Gtk.FileChooserDialog("Add Excluded Directory",
self,
Gtk.FileChooserAction.SELECT_FOLDER,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
response = dlg.run()
- if (response == Gtk.ResponseType.OK):
+ if response == Gtk.ResponseType.OK:
path = dlg.get_filename()
treeview = self.builder.get_object("exclude_treeview")
model = treeview.get_model()
@@ -108,7 +112,7 @@ class CatfishPrefsDialog(PrefsDialog):
self.treemodel_to_settings(model)
dlg.destroy()
- def on_remove_directory_clicked(self, widget):
+ def on_remove_directory_clicked(self, widget): # pylint: disable=W0613
treeview = self.builder.get_object("exclude_treeview")
model = treeview.get_model()
sel = treeview.get_selection().get_selected()
diff --git a/catfish/CatfishSearchEngine.py b/catfish/CatfishSearchEngine.py
index befe63d..69c10cc 100644
--- a/catfish/CatfishSearchEngine.py
+++ b/catfish/CatfishSearchEngine.py
@@ -16,6 +16,10 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+# pylint: disable=C0413
+# pylint: disable=C0114
+# pylint: disable=C0116
+
import logging
import io
@@ -28,31 +32,28 @@ from itertools import permutations
from mimetypes import guess_type
-from sys import version_info
-
import gi
gi.require_version('GLib', '2.0') # noqa
from gi.repository import GLib
try:
- from zeitgeist.client import ZeitgeistDBusInterface
- from zeitgeist.datamodel import Event, TimeRange
- from zeitgeist import datamodel
- iface = ZeitgeistDBusInterface()
- zeitgeist_support = True
-except Exception:
- zeitgeist_support = False
-
-logger = logging.getLogger('catfish_search')
-python3 = version_info[0] > 2
-engine_count = 0
+ from zeitgeist.client import ZeitgeistDBusInterface # pylint: disable=E0401
+ from zeitgeist.datamodel import Event, TimeRange # pylint: disable=E0401
+ from zeitgeist import datamodel # pylint: disable=E0401
+ IFACE = ZeitgeistDBusInterface()
+ ZEITGEIST_SUPPORT = True
+except ImportError:
+ ZEITGEIST_SUPPORT = False
+
+LOGGER = logging.getLogger('catfish_search')
+ENGINE_COUNT = 0
FNULL = open(os.devnull, 'w')
-if subprocess.call(['which', 'locate'],
+if subprocess.call(['which', 'locate'], # pylint: disable=R1703
stdout=FNULL, stderr=subprocess.STDOUT) == 0:
- locate_support = True
+ LOCATE_SUPPORT = True
else:
- locate_support = False
+ LOCATE_SUPPORT = False
FNULL.close()
@@ -69,7 +70,7 @@ def get_keyword_list(keywords):
return kwords
-def string_regex(keywords, path):
+def string_regex(keywords, path): # pylint: disable=W0613
"""Returns a string with the regular expression containing all combinations
of the keywords."""
if len(keywords) == 0:
@@ -108,18 +109,21 @@ class CatfishSearchEngine:
walk 'os.walk' to search for files (like find).
zeitgeist Zeitgeist indexing service to search for files.
"""
- global engine_count
- engine_count += 1
- self.engine_id = engine_count
- logger.debug(
+ self.stop_time = 0
+ self.keywords = ""
+
+ global ENGINE_COUNT
+ ENGINE_COUNT += 1
+ self.engine_id = ENGINE_COUNT
+ LOGGER.debug(
"[%i] engine initializing with methods: %s",
self.engine_id, str(methods))
self.methods = []
if 'zeitgeist' in methods:
- if zeitgeist_support:
+ if ZEITGEIST_SUPPORT:
self.add_method(CatfishSearchMethod_Zeitgeist)
if 'locate' in methods:
- if locate_support:
+ if LOCATE_SUPPORT:
self.add_method(CatfishSearchMethod_Locate)
if 'fulltext' in methods:
self.add_method(CatfishSearchMethod_Fulltext)
@@ -129,13 +133,13 @@ class CatfishSearchEngine:
initialized = []
for method in self.methods:
initialized.append(method.method_name)
- logger.debug(
+ LOGGER.debug(
"[%i] engine initialized with methods: %s",
self.engine_id, str(initialized))
self.start_time = 0.0
def __del__(self):
- logger.debug("[%i] engine destroyed", self.engine_id)
+ LOGGER.debug("[%i] engine destroyed", self.engine_id)
def add_method(self, method_class):
"""Add a CatfishSearchMethod the the engine's search backends."""
@@ -155,7 +159,7 @@ class CatfishSearchEngine:
keywords = get_keyword_list(keywords)
self.keywords = " ".join(keywords)
- logger.debug("[%i] path: %s, keywords: %s, limit: %i, regex: %s",
+ LOGGER.debug("[%i] path: %s, keywords: %s, limit: %i, regex: %s",
self.engine_id, str(path), str(keywords), limit,
str(regex))
@@ -181,9 +185,9 @@ class CatfishSearchEngine:
file_count = 0
for method in self.methods:
if self.stop_time > 0:
- logger.debug("Engine is stopped")
+ LOGGER.debug("Engine is stopped")
return
- logger.debug(
+ LOGGER.debug(
"[%i] Starting search method: %s",
self.engine_id, method.method_name)
for filename in method.run(keywords, path, regex,
@@ -193,7 +197,7 @@ class CatfishSearchEngine:
for filepath in exclude:
if filename.startswith(filepath):
if self.stop_time > 0:
- logger.debug("Engine is stopped")
+ LOGGER.debug("Engine is stopped")
return
found_bad = True
if found_bad:
@@ -202,8 +206,8 @@ class CatfishSearchEngine:
if method.method_name == 'fulltext' or \
all(key in
- os.path.basename(filename).lower()
- for key in keys):
+ os.path.basename(filename).lower()
+ for key in keys):
# Remove the URI portion of the filename if present.
if filename.startswith('file://'):
@@ -261,7 +265,7 @@ class CatfishSearchEngine:
method.stop()
self.stop_time = time.time()
clock = self.stop_time - self.start_time
- logger.debug("[%i] Last query: %f seconds", self.engine_id, clock)
+ LOGGER.debug("[%i] Last query: %f seconds", self.engine_id, clock)
class CatfishSearchMethod:
@@ -273,7 +277,7 @@ class CatfishSearchMethod:
"""Base CatfishSearchMethod Initializer."""
self.method_name = method_name
- def run(self, keywords, path, regex=False, exclude_paths=[]):
+ def run(self, keywords, path, regex=False, exclude_paths=[]): # pylint: disable=W0613
"""Base CatfishSearchMethod run method."""
return NotImplemented
@@ -295,6 +299,7 @@ class CatfishSearchMethod_Walk(CatfishSearchMethod):
def __init__(self):
"""Initialize the 'walk' Search Method."""
CatfishSearchMethod.__init__(self, "walk")
+ self.running = False
def get_dir_list(self, root, dirs, xdg_list,
exclude_list, processed_links):
@@ -449,7 +454,7 @@ class CatfishSearchMethod_Fulltext(CatfishSearchMethod):
find_keywords_backup.append(keyword)
# Start walking the folder structure.
- for root, dirs, files in os.walk(path):
+ for root, dirs, files in os.walk(path): # pylint: disable=W0612
if self.force_stop:
break
@@ -477,7 +482,7 @@ class CatfishSearchMethod_Fulltext(CatfishSearchMethod):
break
else:
if any(keyword in line.lower()
- for keyword in keywords):
+ for keyword in keywords):
found_keywords = []
for find_keyword in find_keywords:
if find_keyword in line.lower():
@@ -517,6 +522,7 @@ class CatfishSearchMethod_Zeitgeist(CatfishSearchMethod):
def __init__(self):
"""Initialize the Zeitgeist SearchMethod."""
CatfishSearchMethod.__init__(self, "zeitgeist")
+ self.stop_search = False
def run(self, keywords, path, regex=False, exclude_paths=[]):
"""Run the Zeitgeist SearchMethod."""
@@ -525,7 +531,7 @@ class CatfishSearchMethod_Zeitgeist(CatfishSearchMethod):
time_range = TimeRange.from_seconds_ago(60 * 3600 * 24)
# 60 days at most
- results = iface.FindEvents(
+ results = IFACE.FindEvents(
time_range, # (min_timestamp, max_timestamp) in milliseconds
[event_template, ],
datamodel.StorageState.Any,
@@ -572,7 +578,7 @@ class CatfishSearchMethodExternal(CatfishSearchMethod):
self.command = []
self.process = None
- def assemble_query(self, keywords, path):
+ def assemble_query(self, keywords, path): # pylint: disable=W0613
"""Base assemble_query method."""
return False
@@ -601,8 +607,7 @@ class CatfishSearchMethodExternal(CatfishSearchMethod):
return map(lambda s: s.decode(encoding='UTF8',
errors='replace').strip(),
output.readlines())
- else:
- return output
+ return output
def status(self):
"""Return the current search status."""
@@ -662,5 +667,4 @@ class CatfishSearchMethod_Locate(CatfishSearchMethodExternal):
if self.caps["regex"]:
return ["locate", "--regex", "--basename", "-i",
"{}".format(string_regex(keywords, path))]
- else:
- return ["locate", "-i", "%path*", str(keywords)]
+ return ["locate", "-i", "%path*", str(keywords)]
diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index 099e439..6fa8a1b 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -16,6 +16,13 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+# pylint: disable=W0201
+# pylint: disable=C0103
+# pylint: disable=C0114
+# pylint: disable=C0116
+# pylint: disable=C0413
+
+
import datetime
import logging
import mimetypes
@@ -27,8 +34,8 @@ from shutil import copy2, rmtree
from xml.sax.saxutils import escape
# Thunar Integration
-import dbus
import urllib
+import dbus
import pexpect
import gi
@@ -42,11 +49,11 @@ from gi.repository import GLib, GObject, Pango, Gdk, GdkPixbuf, Gtk
from catfish.CatfishPrefsDialog import CatfishPrefsDialog
from catfish.CatfishSearchEngine import CatfishSearchEngine
-from catfish_lib import catfishconfig, helpers, get_version, get_about
+from catfish_lib import catfishconfig, helpers, get_about
from catfish_lib import CatfishSettings, SudoDialog, Window
from catfish_lib import Thumbnailer
-logger = logging.getLogger('catfish')
+LOGGER = logging.getLogger('catfish')
# Initialize Gtk, GObject, and mimetypes
@@ -397,7 +404,7 @@ class CatfishWindow(Window):
monitor = m.get_geometry()
return (monitor.width, monitor.height)
- def on_calendar_day_changed(self, widget):
+ def on_calendar_day_changed(self, widget): # pylint: disable=W0613
start_calendar = self.builder.get_named_object(
"dialogs.date.start_calendar")
end_calendar = self.builder.get_named_object(
@@ -441,8 +448,7 @@ class CatfishWindow(Window):
popover = self.get_popover(row[2], builder)
popover.show_all()
return
- else:
- row[3], row[4] = row[4], row[3]
+ row[3], row[4] = row[4], row[3]
else:
row[3], row[4] = row[4], row[3]
if row[2] == 'other' or row[2] == 'custom':
@@ -501,7 +507,7 @@ class CatfishWindow(Window):
self.on_menu_update_index_activate(widget)
widget.hide()
- def on_floating_bar_enter_notify(self, widget, event):
+ def on_floating_bar_enter_notify(self, widget, event): # pylint: disable=W0613
"""Move the floating statusbar when hovered."""
if widget.get_halign() == Gtk.Align.START:
widget.set_halign(Gtk.Align.END)
@@ -536,7 +542,7 @@ class CatfishWindow(Window):
return realpath
return None
- def parse_path_option(self, options, args):
+ def parse_path_option(self, options, args): # pylint: disable=W0613
# Set the selected folder path. Allow legacy --path option.
path = None
@@ -606,7 +612,7 @@ class CatfishWindow(Window):
if self.options.start:
self.on_search_entry_activate(self.search_entry)
- def preview_cell_data_func(self, col, renderer, model, treeiter, data):
+ def preview_cell_data_func(self, col, renderer, model, treeiter, data): # pylint: disable=W0613
"""Cell Renderer Function for the preview."""
icon_name = model[treeiter][0]
filename = model[treeiter][1]
@@ -625,9 +631,8 @@ class CatfishWindow(Window):
pixbuf = self.get_icon_pixbuf(icon_name)
renderer.set_property('pixbuf', pixbuf)
- return
- def thumbnail_cell_data_func(self, col, renderer, model, treeiter, data):
+ def thumbnail_cell_data_func(self, col, renderer, model, treeiter, data): # pylint: disable=W0613
"""Cell Renderer Function to Thumbnails View."""
name, size, path, modified = model[treeiter][1:5]
name = escape(name)
@@ -637,7 +642,6 @@ class CatfishWindow(Window):
displayed = '<b>%s</b> %s%s%s%s%s' % (name, size, os.linesep, path,
os.linesep, modified)
renderer.set_property('markup', displayed)
- return
def load_symbolic_icon(self, icon_name, size, state=Gtk.StateFlags.ACTIVE):
"""Return the symbolic version of icon_name, or the non-symbolic
@@ -682,7 +686,7 @@ class CatfishWindow(Window):
item_date = datetime.datetime.fromtimestamp(modified)
return (locate, db, item_date, changed)
- def on_filters_changed(self, box, row, user_data=None):
+ def on_filters_changed(self, box, row, user_data=None): # pylint: disable=W0613
if row.is_selected():
box.unselect_row(row)
else:
@@ -690,8 +694,8 @@ class CatfishWindow(Window):
return True
# -- Update Search Index dialog -- #
- def on_update_index_dialog_close(self, widget=None, event=None,
- user_data=None):
+ def on_update_index_dialog_close(self, widget=None, event=None, # pylint: disable=W0613
+ user_data=None): # pylint: disable=W0613
"""Close the Update Search Index dialog, resetting to default."""
if not self.update_index_active:
self.update_index_dialog.hide()
@@ -741,7 +745,7 @@ class CatfishWindow(Window):
self.update_index_infobar.show()
- def on_update_index_unlock_clicked(self, widget): # noqa
+ def on_update_index_unlock_clicked(self, widget): # pylint: disable=W0613
"""Unlock admin rights and perform 'updatedb' query."""
self.update_index_active = True
@@ -764,7 +768,7 @@ class CatfishWindow(Window):
self.show_update_status_infobar(2)
return False
- elif response == Gtk.ResponseType.REJECT:
+ if response == Gtk.ResponseType.REJECT:
self.update_index_active = False
self.show_update_status_infobar(3)
return False
@@ -883,7 +887,7 @@ class CatfishWindow(Window):
task = self.perform_query(widget.get_text())
GLib.idle_add(next, task)
- def on_search_entry_icon_press(self, widget, event, user_data):
+ def on_search_entry_icon_press(self, widget, event, user_data): # pylint: disable=W0613
"""If search in progress, stop the search, otherwise, start."""
if not self.search_in_progress:
self.on_search_entry_activate(self.search_entry)
@@ -891,7 +895,7 @@ class CatfishWindow(Window):
self.stop_search = True
self.search_engine.stop()
- def on_search_entry_changed(self, widget):
+ def on_search_entry_changed(self, widget): # pylint: disable=W0613
"""Update the search entry icon and run suggestions."""
text = self.refresh_search_entry()
@@ -959,11 +963,11 @@ class CatfishWindow(Window):
self.filter_format_toggled("fulltext", widget.get_active())
self.on_search_entry_activate(self.search_entry)
- def on_menu_update_index_activate(self, widget):
+ def on_menu_update_index_activate(self, widget): # pylint: disable=W0613
"""Show the Update Search Index dialog."""
self.update_index_dialog.show()
- def on_menu_preferences_activate(self, widget):
+ def on_menu_preferences_activate(self, widget): # pylint: disable=W0613
dialog = CatfishPrefsDialog()
dialog.set_transient_for(self)
dialog.connect_settings(self.settings)
@@ -975,9 +979,9 @@ class CatfishWindow(Window):
def refresh_from_settings(self, changed_properties):
for prop in changed_properties:
setting = self.settings.get_setting(prop)
- if (prop == "show-hidden-files"):
+ if prop == "show-hidden-files":
self.hidden_files.set_active(setting)
- if (prop == "show-sidebar"):
+ if prop == "show-sidebar":
self.set_sidebar_active(setting)
# -- Sidebar -- #
@@ -999,20 +1003,20 @@ class CatfishWindow(Window):
def set_modified_range(self, value):
if value == 'any':
self.filter_timerange = (0.0, 9999999999.0)
- logger.debug("Time Range: Beginning of time -> Eternity")
+ LOGGER.debug("Time Range: Beginning of time -> Eternity")
elif value == 'week':
now = datetime.datetime.now()
week = time.mktime((
datetime.datetime(now.year, now.month, now.day, 0, 0) -
datetime.timedelta(7)).timetuple())
self.filter_timerange = (week, 9999999999.0)
- logger.debug(
+ LOGGER.debug(
"Time Range: %s -> Eternity",
time.strftime("%x %X", time.localtime(int(week))))
elif value == 'custom':
self.filter_timerange = (time.mktime(self.start_date.timetuple()),
time.mktime(self.end_date.timetuple()))
- logger.debug(
+ LOGGER.debug(
"Time Range: %s -> %s",
time.strftime("%x %X",
time.localtime(int(self.filter_timerange[0]))),
@@ -1030,7 +1034,7 @@ class CatfishWindow(Window):
def filter_format_toggled(self, filter_format, enabled):
"""Update search filter when formats are modified."""
self.filter_formats[filter_format] = enabled
- logger.debug("File type filters updated: %s", str(self.filter_formats))
+ LOGGER.debug("File type filters updated: %s", str(self.filter_formats))
self.refilter()
def on_filter_extensions_changed(self, widget):
@@ -1113,7 +1117,7 @@ class CatfishWindow(Window):
def open_file(self, filename):
"""Open the specified filename in its default application."""
- logger.debug("Opening %s" % filename)
+ LOGGER.debug("Opening %s" % filename)
if filename.endswith('.AppImage') and os.access(filename, os.X_OK):
command = [filename]
elif os.path.isdir(filename) and \
@@ -1123,25 +1127,25 @@ class CatfishWindow(Window):
command = ['xdg-open', filename]
try:
subprocess.Popen(command, shell=False)
- if(self.settings.get_setting('close-after-select')):
+ if self.settings.get_setting('close-after-select'):
self.destroy()
return
except Exception as msg:
- logger.debug('Exception encountered while opening %s.' +
+ LOGGER.debug('Exception encountered while opening %s.' +
'\n Exception: %s' +
filename, msg)
self.get_error_dialog(_('\"%s\" could not be opened.') %
os.path.basename(filename), str(msg))
# -- File Popup Menu -- #
- def on_menu_open_activate(self, widget):
+ def on_menu_open_activate(self, widget): # pylint: disable=W0613
"""Open the selected file in its default application."""
for filename in self.selected_filenames:
self.open_file(filename)
- def on_menu_filemanager_activate(self, widget):
+ def on_menu_filemanager_activate(self, widget): # pylint: disable=W0613
"""Open the selected file in the default file manager."""
- logger.debug("Opening file manager for %i path(s)" %
+ LOGGER.debug("Opening file manager for %i path(s)" %
len(self.selected_filenames))
if self.using_thunar_fm():
@@ -1157,9 +1161,9 @@ class CatfishWindow(Window):
for path in dirs:
self.open_file(path)
- def on_menu_copy_location_activate(self, widget):
+ def on_menu_copy_location_activate(self, widget): # pylint: disable=W0613
"""Copy the selected file name to the clipboard."""
- logger.debug("Copying %i filename(s) to the clipboard" %
+ LOGGER.debug("Copying %i filename(s) to the clipboard" %
len(self.selected_filenames))
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
locations = []
@@ -1169,7 +1173,7 @@ class CatfishWindow(Window):
clipboard.set_text(text, -1)
clipboard.store()
- def on_menu_save_activate(self, widget):
+ def on_menu_save_activate(self, widget): # pylint: disable=W0613
"""Show a save dialog and possibly write the results to a file."""
filename = self.get_save_dialog(
surrogate_escape(self.selected_filenames[0]))
@@ -1180,7 +1184,7 @@ class CatfishWindow(Window):
except Exception as msg:
# If the file save fails, throw an error.
- logger.debug('Exception encountered while saving %s.' +
+ LOGGER.debug('Exception encountered while saving %s.' +
'\n Exception: %s', filename, msg)
self.get_error_dialog(_('\"%s\" could not be saved.') %
os.path.basename(filename), str(msg))
@@ -1190,14 +1194,14 @@ class CatfishWindow(Window):
# Delete the file.
if not os.path.exists(filename):
return True
- elif os.path.isdir(filename):
+ if os.path.isdir(filename):
rmtree(filename)
else:
os.remove(filename)
return True
except Exception as msg:
# If the file cannot be deleted, throw an error.
- logger.debug('Exception encountered while deleting %s.' +
+ LOGGER.debug('Exception encountered while deleting %s.' +
'\n Exception: %s', filename, msg)
self.get_error_dialog(_("\"%s\" could not be deleted.") %
os.path.basename(filename),
@@ -1220,7 +1224,7 @@ class CatfishWindow(Window):
treeiter = nextiter
return False
- def on_menu_delete_activate(self, widget):
+ def on_menu_delete_activate(self, widget): # pylint: disable=W0613
"""Show a delete dialog and remove the file if accepted."""
filenames = []
if self.get_delete_dialog(self.selected_filenames):
@@ -1353,7 +1357,7 @@ class CatfishWindow(Window):
self.setup_large_view()
# -- Treeview -- #
- def on_treeview_row_activated(self, treeview, path, user_data):
+ def on_treeview_row_activated(self, treeview, path, user_data): # pylint: disable=W0613
"""Catch row activations by keyboard or mouse double-click."""
# Get the filename from the row.
model = treeview.get_model()
@@ -1363,7 +1367,7 @@ class CatfishWindow(Window):
# Open the selected file.
self.open_file(self.selected_filenames[0])
- def on_treeview_drag_begin(self, treeview, context):
+ def on_treeview_drag_begin(self, treeview, context): # pylint: disable=W0613
"""Treeview DND Begin."""
if len(self.selected_filenames) > 1:
treesel = treeview.get_selection()
@@ -1371,8 +1375,8 @@ class CatfishWindow(Window):
treesel.select_path(row)
return True
- def on_treeview_drag_data_get(self, treeview, context, selection, info,
- time):
+ def on_treeview_drag_data_get(self, treeview, context, selection, info, # pylint: disable=W0613
+ timestamp): # pylint: disable=W0613
"""Treeview DND Get."""
text = str(os.linesep).join(self.selected_filenames)
selection.set_text(text, -1)
@@ -1488,7 +1492,7 @@ class CatfishWindow(Window):
handled = False
return handled
- def new_column(self, label, id, special=None, markup=False):
+ def new_column(self, label, colid, special=None, markup=False):
"""New Column function for creating TreeView columns easily."""
if special == 'icon':
column = Gtk.TreeViewColumn(label)
@@ -1497,46 +1501,44 @@ class CatfishWindow(Window):
column.set_cell_data_func(cell, self.preview_cell_data_func, None)
cell = Gtk.CellRendererText()
column.pack_start(cell, False)
- column.add_attribute(cell, 'text', id)
+ column.add_attribute(cell, 'text', colid)
else:
cell = Gtk.CellRendererText()
if markup:
- column = Gtk.TreeViewColumn(label, cell, markup=id)
+ column = Gtk.TreeViewColumn(label, cell, markup=colid)
else:
- column = Gtk.TreeViewColumn(label, cell, text=id)
+ column = Gtk.TreeViewColumn(label, cell, text=colid)
if special == 'ellipsize':
column.set_min_width(120)
cell.set_property('ellipsize', Pango.EllipsizeMode.START)
elif special == 'filesize':
cell.set_property('xalign', 1.0)
column.set_cell_data_func(cell,
- self.cell_data_func_filesize, id)
+ self.cell_data_func_filesize, colid)
elif special == 'date':
column.set_cell_data_func(cell,
- self.cell_data_func_modified, id)
- column.set_sort_column_id(id)
+ self.cell_data_func_modified, colid)
+ column.set_sort_column_id(colid)
column.set_resizable(True)
- if id == 3:
+ if colid == 3:
column.set_expand(True)
return column
- def cell_data_func_filesize(self, column, cell_renderer,
- tree_model, tree_iter, id):
+ def cell_data_func_filesize(self, column, cell_renderer, # pylint: disable=W0613
+ tree_model, tree_iter, cellid):
"""File size cell display function."""
- size = long(tree_model.get_value(tree_iter, id))
+ size = long(tree_model.get_value(tree_iter, cellid))
filesize = self.format_size(size)
cell_renderer.set_property('text', filesize)
- return
- def cell_data_func_modified(self, column, cell_renderer,
- tree_model, tree_iter, id):
+ def cell_data_func_modified(self, column, cell_renderer, # pylint: disable=W0613
+ tree_model, tree_iter, cellid):
"""Modification date cell display function."""
- modification_int = int(tree_model.get_value(tree_iter, id))
+ modification_int = int(tree_model.get_value(tree_iter, cellid))
modified = self.get_date_string(modification_int)
cell_renderer.set_property('text', modified)
- return
def get_date_string(self, modification_int):
"""Return the date string in the preferred format."""
@@ -1557,28 +1559,28 @@ class CatfishWindow(Window):
time.localtime(modification_int))
return modified
- def results_filter_func(self, model, iter, user_data): # noqa
+ def results_filter_func(self, model, treeiter, user_data): # pylint: disable=W0613
"""Filter function for search results."""
# hidden
- if model[iter][6]:
+ if model[treeiter][6]:
if not self.filter_formats['hidden']:
return False
# exact
if not self.filter_formats['fulltext']:
- if not model[iter][7]:
+ if not model[treeiter][7]:
if self.filter_formats['exact']:
return False
# modified
- modified = model[iter][4]
+ modified = model[treeiter][4]
if modified < self.filter_timerange[0]:
return False
if modified > self.filter_timerange[1]:
return False
# mimetype
- mimetype = model[iter][5]
+ mimetype = model[treeiter][5]
use_filters = False
if self.filter_formats['folders']:
use_filters = True
@@ -1606,7 +1608,7 @@ class CatfishWindow(Window):
return True
if self.filter_formats['other']:
use_filters = True
- extension = os.path.splitext(model[iter][1])[1]
+ extension = os.path.splitext(model[treeiter][1])[1]
if extension in self.filter_custom_extensions:
return True
@@ -1653,8 +1655,7 @@ class CatfishWindow(Window):
suffixIndex += 1
size = size / 1024.0
return "%.*f %s" % (precision, size, suffixes[suffixIndex])
- else:
- return "%i %s" % (size, suffixes[0])
+ return "%i %s" % (size, suffixes[0])
def guess_mimetype(self, filename):
"""Guess the mimetype of the specified filename.
@@ -1715,39 +1716,37 @@ class CatfishWindow(Window):
return thumb
return self.get_file_icon(path, mime_type)
- def get_file_icon(self, path, mime_type=None):
+ def get_file_icon(self, path, mime_type=None): # pylint: disable=W0613
"""Retrieve the file icon."""
if mime_type:
if mime_type == 'inode/directory':
return "folder"
- else:
- mime_type = mime_type.split('/')
- if mime_type is not None:
- # Get icon from mimetype
- media, subtype = mime_type
-
- variations = ['%s-%s' % (media, subtype),
- '%s-x-%s' % (media, subtype)]
- if media == "application":
- variations.append('application-x-executable')
- variations.append('%s-x-generic' % media)
-
- for icon_name in variations:
- if self.icon_theme.has_icon(icon_name):
- return icon_name
+ mime_type = mime_type.split('/')
+ if mime_type is not None:
+ # Get icon from mimetype
+ media, subtype = mime_type
+
+ variations = ['%s-%s' % (media, subtype),
+ '%s-x-%s' % (media, subtype)]
+ if media == "application":
+ variations.append('application-x-executable')
+ variations.append('%s-x-generic' % media)
+
+ for icon_name in variations:
+ if self.icon_theme.has_icon(icon_name):
+ return icon_name
return "text-x-generic"
- def size_sort_func(self, model, row1, row2, user_data):
+ def size_sort_func(self, model, row1, row2, user_data): # pylint: disable=W0613
"""Sort function used in Python 3."""
sort_column = 2
value1 = long(model.get_value(row1, sort_column))
value2 = long(model.get_value(row2, sort_column))
if value1 < value2:
return -1
- elif value1 == value2:
+ if value1 == value2:
return 0
- else:
- return 1
+ return 1
# -- Searching -- #
def perform_query(self, keywords): # noqa
@@ -1845,7 +1844,7 @@ class CatfishWindow(Window):
# file no longer exists
pass
except Exception as e:
- logger.error("Exception encountered: %s" % str(e))
+ LOGGER.error("Exception encountered: %s" % str(e))
yield True
continue
diff --git a/catfish/__init__.py b/catfish/__init__.py
index 4e3881b..c95f4a5 100644
--- a/catfish/__init__.py
+++ b/catfish/__init__.py
@@ -16,7 +16,10 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+# pylint: disable=C0413
+
import optparse
+import signal
import sys
from locale import gettext as _
@@ -28,9 +31,7 @@ from gi.repository import Gtk
from catfish import CatfishWindow
-from catfish_lib import set_up_logging, get_version, check_x11_session
-
-import signal
+from catfish_lib import set_up_logging, get_version
def parse_options():
diff --git a/catfish_lib/Builder.py b/catfish_lib/Builder.py
index 5b4c067..8c5d62e 100644
--- a/catfish_lib/Builder.py
+++ b/catfish_lib/Builder.py
@@ -18,13 +18,13 @@
'''Enhances builder connections, provides object to access glade objects'''
-from gi.repository import GObject, Gtk # pylint: disable=E0611
-
import inspect
import functools
import logging
from xml.etree.cElementTree import ElementTree
+from gi.repository import GObject, Gtk # pylint: disable=E0611
+
logger = logging.getLogger('catfish_lib')
# this module is big so uses some conventional prefixes and postfixes
diff --git a/catfish_lib/CatfishSettings.py b/catfish_lib/CatfishSettings.py
index d0819ea..d28fb21 100644
--- a/catfish_lib/CatfishSettings.py
+++ b/catfish_lib/CatfishSettings.py
@@ -18,9 +18,9 @@
import os
-default_settings_file = os.path.join(os.getenv('HOME'),
+DEFAULT_SETTINGS_FILE = os.path.join(os.getenv('HOME'),
'.config/catfish/catfish.rc')
-default_settings = {
+DEFAULT_SETTINGS = {
'use-headerbar': None,
'show-hidden-files': False,
'show-sidebar': False,
@@ -37,7 +37,7 @@ class CatfishSettings:
"""CatfishSettings rc-file management."""
- def __init__(self, settings_file=default_settings_file):
+ def __init__(self, settings_file=DEFAULT_SETTINGS_FILE):
"""Initialize the CatfishSettings instance."""
try:
settings_dir = os.path.dirname(settings_file)
@@ -65,9 +65,9 @@ class CatfishSettings:
def get_setting(self, key):
"""Return current setting for specified key."""
if key in self.settings:
- if (key.startswith('window')):
+ if key.startswith('window'):
return int(self.settings[key])
- if (key == "exclude-paths"):
+ if key == "exclude-paths":
exclude_directories = []
for path in (self.settings[key].strip()).split(";"):
if len(path) > 0:
@@ -78,8 +78,7 @@ class CatfishSettings:
exclude_directories.sort()
return exclude_directories
return self.settings[key]
- else:
- return None
+ return None
def set_setting(self, key, value):
"""Set the value for the specified key."""
@@ -94,7 +93,7 @@ class CatfishSettings:
def read(self):
"""Read the settings rc-file into this settings instance."""
- self.settings = default_settings.copy()
+ self.settings = DEFAULT_SETTINGS.copy()
if os.path.isfile(self.settings_file):
try:
for line in open(self.settings_file):
diff --git a/catfish_lib/SudoDialog.py b/catfish_lib/SudoDialog.py
index 39f7b64..75ecc39 100644
--- a/catfish_lib/SudoDialog.py
+++ b/catfish_lib/SudoDialog.py
@@ -16,13 +16,13 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
-from gi.repository import Gtk, GdkPixbuf
import os
-
from locale import gettext as _
import pexpect
+from gi.repository import Gtk, GdkPixbuf
+
gtk_version = (Gtk.get_major_version(),
Gtk.get_minor_version(),
Gtk.get_micro_version())
@@ -66,12 +66,9 @@ def check_dependencies(commands=[]):
index = child.expect([".*ssword.*", "Sorry",
pexpect.EOF, pexpect.TIMEOUT])
child.close()
- if index == 0 or index == 2:
+ if index in [0, 2]:
# User in sudoers, or already admin
return True
- elif index == 1 or index == 3:
- # User not in sudoers
- return False
except Exception:
# Something else went wrong.
@@ -226,6 +223,7 @@ class SudoDialog(Gtk.Dialog):
self.attempted_logins = 0
self.max_attempted_logins = retries
+ self.password_valid = False
def on_password_changed(self, widget, button):
"""Set the apply button sensitivity based on password input."""
@@ -268,12 +266,12 @@ class SudoDialog(Gtk.Dialog):
self.dialog_icon.set_from_icon_name('dialog-password', icon_size)
self.set_icon_name('dialog-password')
- def on_show(self, widget):
+ def on_show(self, widget): # pylint: disable=W0613
'''When the dialog is displayed, clear the password.'''
self.set_password('')
self.password_valid = False
- def on_ok_clicked(self, widget):
+ def on_ok_clicked(self, widget): # pylint: disable=W0613
'''
When the OK button is clicked, attempt to use sudo with the currently
entered password. If successful, emit the response signal with ACCEPT.
@@ -331,6 +329,5 @@ class SudoDialog(Gtk.Dialog):
if child.exitstatus == 0:
self.attempted_logins = 0
return True
- else:
- self.attempted_logins += 1
- return False
+ self.attempted_logins += 1
+ return False
diff --git a/catfish_lib/Thumbnailer.py b/catfish_lib/Thumbnailer.py
index 511fffa..dc2b9b9 100644
--- a/catfish_lib/Thumbnailer.py
+++ b/catfish_lib/Thumbnailer.py
@@ -182,16 +182,19 @@ class Thumbnailer:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
if pixbuf is None:
return False
+
pixbuf_w = pixbuf.get_width()
pixbuf_h = pixbuf.get_height()
if pixbuf_w < 1 or pixbuf_h < 1:
return False
+
if pixbuf_w < 128 and pixbuf_h < 128:
options = self._get_attributes(filename)
pixbuf.savev(thumbnail, "png", list(options.keys()),
list(options.values()))
os.chmod(thumbnail, 0o600)
return True
+
if pixbuf_w > pixbuf_h:
thumb_w = 128
thumb_h = int(pixbuf_h / (pixbuf_w / 128.0))
@@ -200,10 +203,12 @@ class Thumbnailer:
thumb_w = int(pixbuf_w / (pixbuf_h / 128.0))
if thumb_w < 1 or thumb_h < 1:
return False
+
thumb_pixbuf = pixbuf.scale_simple(
thumb_w, thumb_h, GdkPixbuf.InterpType.BILINEAR)
if thumb_pixbuf is None:
return False
+
options = self._get_attributes(filename)
thumb_pixbuf.savev(thumbnail, "png", list(options.keys()),
list(options.values()))
@@ -244,6 +249,5 @@ class Thumbnailer:
normal = self._get_normal_filename(filename)
if self._create_thumbnail(filename, normal):
return normal
- else:
- self._write_fail(filename)
- return False
+ self._write_fail(filename)
+ return False
diff --git a/catfish_lib/Window.py b/catfish_lib/Window.py
index 537a75c..38f4873 100644
--- a/catfish_lib/Window.py
+++ b/catfish_lib/Window.py
@@ -16,12 +16,16 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
-from gi.repository import Gtk, Gdk # pylint: disable=E0611
+# pylint: disable=C0114
+# pylint: disable=C0116
+
import logging
from locale import gettext as _
-from . helpers import get_builder
+from gi.repository import Gtk, Gdk # pylint: disable=E0611
+
from catfish_lib import CatfishSettings
+from . helpers import get_builder
logger = logging.getLogger('catfish_lib')
@@ -251,7 +255,7 @@ class Window(Gtk.Window):
self.get_children()[0].reorder_child(toolbar, 0)
toolbar.show_all()
- def on_mnu_about_activate(self, widget, data=None):
+ def on_mnu_about_activate(self, widget, data=None): # pylint: disable=W0613
"""Display the about box for catfish."""
if self.AboutDialog is not None:
about = self.AboutDialog() # pylint: disable=E1102
@@ -259,13 +263,13 @@ class Window(Gtk.Window):
about.run()
about.destroy()
- def on_destroy(self, widget, data=None):
+ def on_destroy(self, widget, data=None): # pylint: disable=W0613
"""Called when the CatfishWindow is closed."""
self.search_engine.stop()
self.settings.write()
Gtk.main_quit()
- def on_catfish_window_window_state_event(self, widget, event):
+ def on_catfish_window_window_state_event(self, widget, event): # pylint: disable=W0613
"""Properly handle window-manager fullscreen events."""
self.window_is_fullscreen = bool(event.new_window_state &
Gdk.WindowState.FULLSCREEN)
@@ -286,7 +290,7 @@ class Window(Gtk.Window):
def map_key(self, key):
if key.endswith("_L"):
return key.replace("_L", "")
- elif key.endswith("_R"):
+ if key.endswith("_R"):
return key.replace("_R", "")
return key
@@ -339,13 +343,13 @@ class Window(Gtk.Window):
return True
return False
- def on_catfish_window_key_release_event(self, widget, event):
+ def on_catfish_window_key_release_event(self, widget, event): # pylint: disable=W0613
"""Handle key releases for the Catfish window."""
keys = self.get_keys_from_event(event)
self.remove_keys(keys)
return False
- def on_catfish_window_size_allocate(self, widget, allocation):
+ def on_catfish_window_size_allocate(self, widget, allocation): # pylint: disable=W0613
paned = self.builder.get_named_object("window.paned")
allocation = paned.get_allocation()
self.settings.set_setting('window-height', allocation.height)
@@ -353,7 +357,7 @@ class Window(Gtk.Window):
paned.set_property('height_request', -1)
paned.set_property('width_request', -1)
- def on_catfish_window_configure_event(self, widget, event):
+ def on_catfish_window_configure_event(self, widget, event): # pylint: disable=W0613
pos = self.get_position()
self.settings.set_setting('window-x', pos.root_x)
self.settings.set_setting('window-y', pos.root_y)
diff --git a/catfish_lib/__init__.py b/catfish_lib/__init__.py
index 50e67c8..2475759 100644
--- a/catfish_lib/__init__.py
+++ b/catfish_lib/__init__.py
@@ -19,6 +19,6 @@
'''facade - makes catfish_lib package easy to refactor
while keeping its api constant'''
-from . helpers import set_up_logging, check_x11_session # noqa
+from . helpers import set_up_logging # noqa
from . Window import Window # noqa
from . catfishconfig import get_version, get_about # noqa
diff --git a/catfish_lib/catfishconfig.py b/catfish_lib/catfishconfig.py
index 9821703..ebd5a0e 100644
--- a/catfish_lib/catfishconfig.py
+++ b/catfish_lib/catfishconfig.py
@@ -90,7 +90,7 @@ def get_about():
'website': __url__,
'comments': _('Catfish is a versatile file searching tool.'),
'copyright': 'Copyright (C) 2007-2012 Christian Dywan <christian at twotoasts.de>\n'
- 'Copyright (C) 2012-2019 Sean Davis <bluesabre at xfce.org>',
+ 'Copyright (C) 2012-2019 Sean Davis <bluesabre at xfce.org>',
'authors': [
'Christian Dywan <christian at twotoasts.de>',
'Sean Davis <bluesabre at xfce.org>'],
diff --git a/catfish_lib/helpers.py b/catfish_lib/helpers.py
index 8cdbc3b..d6c4dd2 100644
--- a/catfish_lib/helpers.py
+++ b/catfish_lib/helpers.py
@@ -16,17 +16,17 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
+# pylint: disable=C0413
+
"""Helpers for an Ubuntu application."""
import logging
import os
import sys
import gi
-gi.require_version('GLib', '2.0') # noqa
gi.require_version('GObject', '2.0') # noqa
-gi.require_version('Gdk', '3.0') # noqa
gi.require_version('Gtk', '3.0') # noqa
-from gi.repository import GLib, GObject, Gdk, Gtk
+from gi.repository import GObject, Gtk
from . catfishconfig import get_data_file
from . Builder import Builder
@@ -181,7 +181,6 @@ def get_help_uri(page=None):
def show_uri(parent, link):
"""Open the specified URI."""
- from gi.repository import Gtk # pylint: disable=E0611
screen = parent.get_screen()
Gtk.show_uri(screen, link, Gtk.get_current_event_time())
@@ -195,24 +194,3 @@ def alias(alternative_function_name):
function.aliases.append(alternative_function_name)
return function
return decorator
-
-
-def check_x11_session():
- '''Is it an X.org session?'''
- backend_env = GLib.environ_getenv(GLib.get_environ(), 'GDK_BACKEND')
- if backend_env is None:
- # We look for default display
- display = Gdk.Display.get_default()
- if display is None:
- return True
-
- name = display.get_name()
- if name.startswith('wayland'):
- return False
- else:
- return True
- else:
- if backend_env.lower() == 'x11':
- return True
- else:
- return False
diff --git a/po/catfish.pot b/po/catfish.pot
index 262a211..157d627 100644
--- a/po/catfish.pot
+++ b/po/catfish.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-01-01 08:11-0500\n"
+"POT-Creation-Date: 2020-01-01 12:41-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -193,7 +193,7 @@ msgstr ""
msgid "<b>End Date</b>"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:23 ../catfish_lib/Window.py:224
+#: ../data/ui/CatfishWindow.ui.h:23 ../catfish_lib/Window.py:228
msgid "Catfish"
msgstr ""
@@ -209,11 +209,11 @@ msgstr ""
msgid "File Type"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1313
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1316
msgid "Modified"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1763
+#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1761
msgid "Results will be displayed as soon as they are found."
msgstr ""
@@ -223,8 +223,8 @@ msgstr ""
#. Restore Cancel button
#. Buttons
-#: ../data/ui/CatfishWindow.ui.h:31 ../catfish/CatfishWindow.py:707
-#: ../catfish_lib/SudoDialog.py:196
+#: ../data/ui/CatfishWindow.ui.h:31 ../catfish/CatfishWindow.py:711
+#: ../catfish_lib/SudoDialog.py:193
msgid "Cancel"
msgstr ""
@@ -294,44 +294,44 @@ msgstr ""
msgid "_About"
msgstr ""
-#: ../catfish/__init__.py:38
+#: ../catfish/__init__.py:39
msgid "Usage: %prog [options] path query"
msgstr ""
-#: ../catfish/__init__.py:43
+#: ../catfish/__init__.py:44
msgid "Show debug messages (-vv will also debug catfish_lib)"
msgstr ""
-#: ../catfish/__init__.py:46
+#: ../catfish/__init__.py:47
msgid "Use large icons"
msgstr ""
-#: ../catfish/__init__.py:48
+#: ../catfish/__init__.py:49
msgid "Use thumbnails"
msgstr ""
-#: ../catfish/__init__.py:50
+#: ../catfish/__init__.py:51
msgid "Display time in ISO format"
msgstr ""
#. Translators: Do not translate PATH, it is a variable.
-#: ../catfish/__init__.py:52
+#: ../catfish/__init__.py:53
msgid "Set the default search path"
msgstr ""
-#: ../catfish/__init__.py:54
+#: ../catfish/__init__.py:55
msgid "Perform exact match"
msgstr ""
-#: ../catfish/__init__.py:56
+#: ../catfish/__init__.py:57
msgid "Include hidden files"
msgstr ""
-#: ../catfish/__init__.py:58
+#: ../catfish/__init__.py:59
msgid "Perform fulltext search"
msgstr ""
-#: ../catfish/__init__.py:60
+#: ../catfish/__init__.py:61
msgid ""
"If path and query are provided, start searching when the application is "
"displayed."
@@ -339,169 +339,169 @@ msgstr ""
#. Translators: this text is displayed next to
#. a filename that is not utf-8 encoded.
-#: ../catfish/CatfishWindow.py:99
+#: ../catfish/CatfishWindow.py:106
#, python-format
msgid "%s (invalid encoding)"
msgstr ""
-#: ../catfish/CatfishWindow.py:139
+#: ../catfish/CatfishWindow.py:146
msgid "translator-credits"
msgstr ""
-#: ../catfish/CatfishWindow.py:279
+#: ../catfish/CatfishWindow.py:286
msgid "Unknown"
msgstr ""
-#: ../catfish/CatfishWindow.py:283
+#: ../catfish/CatfishWindow.py:290
msgid "Never"
msgstr ""
-#: ../catfish/CatfishWindow.py:362
+#: ../catfish/CatfishWindow.py:369
#, python-format
msgid ""
"Enter your query above to find your files\n"
"or click the %s icon for more options."
msgstr ""
-#: ../catfish/CatfishWindow.py:722
+#: ../catfish/CatfishWindow.py:726
msgid "An error occurred while updating the database."
msgstr ""
-#: ../catfish/CatfishWindow.py:724
+#: ../catfish/CatfishWindow.py:728
msgid "Authentication failed."
msgstr ""
-#: ../catfish/CatfishWindow.py:730
+#: ../catfish/CatfishWindow.py:734
msgid "Authentication cancelled."
msgstr ""
-#: ../catfish/CatfishWindow.py:736
+#: ../catfish/CatfishWindow.py:740
msgid "Search database updated successfully."
msgstr ""
#. Update the Cancel button to Close, make it default
-#: ../catfish/CatfishWindow.py:797
+#: ../catfish/CatfishWindow.py:801
msgid "Close"
msgstr ""
#. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:811
+#: ../catfish/CatfishWindow.py:815
msgid "Updating..."
msgstr ""
-#: ../catfish/CatfishWindow.py:845
+#: ../catfish/CatfishWindow.py:849
msgid "Stop Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:846
+#: ../catfish/CatfishWindow.py:850
msgid ""
"Search is in progress...\n"
"Press the cancel button or the Escape key to stop."
msgstr ""
-#: ../catfish/CatfishWindow.py:855
+#: ../catfish/CatfishWindow.py:859
msgid "Begin Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:1133
+#: ../catfish/CatfishWindow.py:1137
#, python-format
msgid "\"%s\" could not be opened."
msgstr ""
-#: ../catfish/CatfishWindow.py:1185
+#: ../catfish/CatfishWindow.py:1189
#, python-format
msgid "\"%s\" could not be saved."
msgstr ""
-#: ../catfish/CatfishWindow.py:1202
+#: ../catfish/CatfishWindow.py:1206
#, python-format
msgid "\"%s\" could not be deleted."
msgstr ""
-#: ../catfish/CatfishWindow.py:1242
+#: ../catfish/CatfishWindow.py:1245
#, python-format
msgid "Save \"%s\" as..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1277
+#: ../catfish/CatfishWindow.py:1280
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete \"%s\"?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1281
+#: ../catfish/CatfishWindow.py:1284
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete the %i selected files?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1284
+#: ../catfish/CatfishWindow.py:1287
msgid "If you delete a file, it is permanently lost."
msgstr ""
-#: ../catfish/CatfishWindow.py:1307
+#: ../catfish/CatfishWindow.py:1310
msgid "Filename"
msgstr ""
-#: ../catfish/CatfishWindow.py:1309
+#: ../catfish/CatfishWindow.py:1312
msgid "Size"
msgstr ""
-#: ../catfish/CatfishWindow.py:1311
+#: ../catfish/CatfishWindow.py:1314
msgid "Location"
msgstr ""
-#: ../catfish/CatfishWindow.py:1323
+#: ../catfish/CatfishWindow.py:1326
msgid "Preview"
msgstr ""
-#: ../catfish/CatfishWindow.py:1331
+#: ../catfish/CatfishWindow.py:1334
msgid "Details"
msgstr ""
-#: ../catfish/CatfishWindow.py:1550
+#: ../catfish/CatfishWindow.py:1551
msgid "Today"
msgstr ""
-#: ../catfish/CatfishWindow.py:1552
+#: ../catfish/CatfishWindow.py:1553
msgid "Yesterday"
msgstr ""
-#: ../catfish/CatfishWindow.py:1633
+#: ../catfish/CatfishWindow.py:1634
msgid "No files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1635
+#: ../catfish/CatfishWindow.py:1636
msgid ""
"Try making your search less specific\n"
"or try another directory."
msgstr ""
-#: ../catfish/CatfishWindow.py:1642
+#: ../catfish/CatfishWindow.py:1643
msgid "1 file found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1644
+#: ../catfish/CatfishWindow.py:1645
#, python-format
msgid "%i files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1650
+#: ../catfish/CatfishWindow.py:1651
msgid "bytes"
msgstr ""
-#: ../catfish/CatfishWindow.py:1761 ../catfish/CatfishWindow.py:1771
+#: ../catfish/CatfishWindow.py:1759 ../catfish/CatfishWindow.py:1769
msgid "Searching..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1769
+#: ../catfish/CatfishWindow.py:1767
#, python-format
msgid "Searching for \"%s\""
msgstr ""
-#: ../catfish/CatfishWindow.py:1858
+#: ../catfish/CatfishWindow.py:1856
#, python-format
msgid "Search results for \"%s\""
msgstr ""
@@ -510,29 +510,29 @@ msgstr ""
msgid "Catfish is a versatile file searching tool."
msgstr ""
-#: ../catfish_lib/SudoDialog.py:138
+#: ../catfish_lib/SudoDialog.py:135
msgid "Password Required"
msgstr ""
-#: ../catfish_lib/SudoDialog.py:175
+#: ../catfish_lib/SudoDialog.py:172
msgid "Incorrect password... try again."
msgstr ""
-#: ../catfish_lib/SudoDialog.py:185
+#: ../catfish_lib/SudoDialog.py:182
msgid "Password:"
msgstr ""
-#: ../catfish_lib/SudoDialog.py:199
+#: ../catfish_lib/SudoDialog.py:196
msgid "OK"
msgstr ""
-#: ../catfish_lib/SudoDialog.py:220
+#: ../catfish_lib/SudoDialog.py:217
msgid ""
"Enter your password to\n"
"perform administrative tasks."
msgstr ""
-#: ../catfish_lib/SudoDialog.py:222
+#: ../catfish_lib/SudoDialog.py:219
#, python-format
msgid ""
"The application '%s' lets you\n"
diff --git a/setup.py b/setup.py
index af9b6a6..d67c4a0 100644
--- a/setup.py
+++ b/setup.py
@@ -59,7 +59,7 @@ def update_config(libdir, values={}):
return oldvalues
-def move_icon_file(root, target_data, prefix):
+def move_icon_file(root, target_data):
"""Move the icon files to their installation prefix."""
old_icon_path = os.path.normpath(
os.path.join(root, target_data, 'share', 'catfish', 'media'))
@@ -90,7 +90,7 @@ def move_icon_file(root, target_data, prefix):
return icon_file
-def get_desktop_file(root, target_data, prefix):
+def get_desktop_file(root, target_data):
"""Move the desktop file to its installation prefix."""
desktop_path = os.path.realpath(
os.path.join(root, target_data, 'share', 'applications'))
@@ -153,7 +153,7 @@ class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
self.distribution.get_version())))
if not self.prefix:
- self.prefix = ''
+ self.prefix = '' # pylint: disable=W0201
if self.root:
target_data = os.path.relpath(
@@ -164,7 +164,7 @@ class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
script_path = os.path.join(self.prefix, 'bin')
else:
# --user install
- self.root = ''
+ self.root = '' # pylint: disable=W0201
target_data = os.path.relpath(self.install_data) + os.sep
target_pkgdata = os.path.join(target_data, 'share', 'catfish', '')
target_scripts = os.path.join(self.install_scripts, '')
@@ -188,9 +188,9 @@ class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
'__version__': "'%s'" % self.distribution.get_version()}
update_config(self.install_lib, values)
- desktop_file = get_desktop_file(self.root, target_data, self.prefix)
+ desktop_file = get_desktop_file(self.root, target_data)
print(("Desktop File: %s\n" % desktop_file))
- move_icon_file(self.root, target_data, self.prefix)
+ move_icon_file(self.root, target_data)
update_desktop_file(desktop_file, script_path)
cleanup_metainfo_files(self.root, target_data)
@@ -198,18 +198,18 @@ class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
# Verify the build directory is clean
-folder = "dist/catfish-%s" % __version__
-if os.path.exists(folder):
+FOLDER = "dist/catfish-%s" % __version__
+if os.path.exists(FOLDER):
sys.stderr.write("Build directory 'dist' is not clean.\n"
- "Please manually remove %s" % folder)
+ "Please manually remove %s" % FOLDER)
sys.exit(1)
# Hacky, default releases to bztar
-default_release_build = False
+DEFAULT_RELEASE_BUILD = False
if "sdist" in sys.argv:
if "--formats" not in " ".join(sys.argv[1:]):
sys.argv.append("--formats=bztar")
- default_release_build = True
+ DEFAULT_RELEASE_BUILD = True
DistUtilsExtra.auto.setup(
name='catfish',
@@ -231,40 +231,40 @@ DistUtilsExtra.auto.setup(
)
# Simplify Xfce release process by providing sums
-if default_release_build:
+if DEFAULT_RELEASE_BUILD:
import hashlib
import tarfile
- bzfile = "dist/catfish-%s.tar.bz2" % __version__
- if not os.path.exists(bzfile):
+ BZFILE = "dist/catfish-%s.tar.bz2" % __version__
+ if not os.path.exists(BZFILE):
sys.stderr.write("Expected file '%s' was not found.")
sys.exit(1)
- contents = open(bzfile, 'rb').read()
+ CONTENTS = open(BZFILE, 'rb').read()
print("")
- print("%s written" % bzfile)
- print(" MD5: %s" % hashlib.md5(contents).hexdigest())
- print(" SHA1: %s" % hashlib.sha1(contents).hexdigest())
- print(" SHA256: %s" % hashlib.sha256(contents).hexdigest())
+ print("%s written" % BZFILE)
+ print(" MD5: %s" % hashlib.md5(CONTENTS).hexdigest())
+ print(" SHA1: %s" % hashlib.sha1(CONTENTS).hexdigest())
+ print(" SHA256: %s" % hashlib.sha256(CONTENTS).hexdigest())
print("")
print("Contents:")
- contents = {}
- tar = tarfile.open(bzfile, "r:bz2")
- for tarinfo in tar:
+ CONTENTS = {}
+ TAR = tarfile.open(BZFILE, "r:bz2")
+ for tarinfo in TAR:
if not tarinfo.isdir():
basedir = os.path.dirname(tarinfo.name)
- if basedir not in contents.keys():
- contents[basedir] = []
- contents[basedir].append(tarinfo.name)
- tar.close()
+ if basedir not in CONTENTS.keys():
+ CONTENTS[basedir] = []
+ CONTENTS[basedir].append(tarinfo.name)
+ TAR.close()
- for basedir in contents.keys():
+ for basedir in CONTENTS.keys(): # pylint: disable=C0201
indent = ""
for i in range(0, len(basedir.split("/"))):
indent += " "
print("%s%s/" % (indent, basedir))
indent += " "
- for filename in contents[basedir]:
- print(indent + filename)
+ for fname in CONTENTS[basedir]:
+ print(indent + fname)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list