[Xfce4-commits] [apps/catfish] 01/01: Various Flake8 improvements
noreply at xfce.org
noreply at xfce.org
Sat Aug 24 19:32:38 CEST 2019
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 22550d700e4fbe0e2ed6ba18a7d937bfb027be10
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sat Aug 24 13:32:33 2019 -0400
Various Flake8 improvements
---
catfish/CatfishSearchEngine.py | 5 ++-
catfish/CatfishWindow.py | 28 +++++++++-------
catfish_lib/CatfishSettings.py | 5 +--
catfish_lib/Thumbnailer.py | 34 +++++++++++--------
catfish_lib/Window.py | 2 +-
catfish_lib/helpers.py | 9 +++--
po/catfish.pot | 76 +++++++++++++++++++++---------------------
7 files changed, 86 insertions(+), 73 deletions(-)
diff --git a/catfish/CatfishSearchEngine.py b/catfish/CatfishSearchEngine.py
index 63dc566..87d24ee 100644
--- a/catfish/CatfishSearchEngine.py
+++ b/catfish/CatfishSearchEngine.py
@@ -51,6 +51,7 @@ else:
locate_support = False
FNULL.close()
+
def get_keyword_list(keywords):
keywords = keywords.replace(",", " ").strip().lower()
kwords = []
@@ -63,6 +64,7 @@ def get_keyword_list(keywords):
kwords.append(keyword.replace("\0", " "))
return kwords
+
def string_regex(keywords, path):
"""Returns a string with the regular expression containing all combinations
of the keywords."""
@@ -512,7 +514,8 @@ class CatfishSearchMethodExternal(CatfishSearchMethod):
def process_output(self, output):
"""Return the output text."""
if isinstance(output, io.BufferedReader):
- return map(lambda s: s.decode(encoding='UTF8', errors='replace').strip(),
+ return map(lambda s: s.decode(encoding='UTF8',
+ errors='replace').strip(),
output.readlines())
else:
return output
diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index 7db3b2b..6118353 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -17,7 +17,6 @@
# with this program. If not, see <https://www.gnu.org/licenses/>.
import datetime
-import hashlib
import logging
import mimetypes
import os
@@ -33,12 +32,12 @@ import urllib
import pexpect
import gi
-gi.require_version('GLib', '2.0')
-gi.require_version('GObject', '2.0')
-gi.require_version('Pango', '1.0')
-gi.require_version('Gdk', '3.0')
-gi.require_version('GdkPixbuf', '2.0')
-gi.require_version('Gtk', '3.0')
+gi.require_version('GLib', '2.0') # noqa
+gi.require_version('GObject', '2.0') # noqa
+gi.require_version('Pango', '1.0') # noqa
+gi.require_version('Gdk', '3.0') # noqa
+gi.require_version('GdkPixbuf', '2.0') # noqa
+gi.require_version('Gtk', '3.0') # noqa
from gi.repository import GLib, GObject, Pango, Gdk, GdkPixbuf, Gtk
from catfish.AboutCatfishDialog import AboutCatfishDialog
@@ -281,8 +280,10 @@ class CatfishWindow(Window):
self.settings = CatfishSettings.CatfishSettings()
paned = builder.get_named_object("window.paned")
- paned.set_property('height_request', self.settings.get_setting('window-height'))
- paned.set_property('width_request', self.settings.get_setting('window-width'))
+ paned.set_property('height_request',
+ self.settings.get_setting('window-height'))
+ paned.set_property('width_request',
+ self.settings.get_setting('window-width'))
window_width = self.settings.get_setting('window-width')
window_height = self.settings.get_setting('window-height')
@@ -342,7 +343,8 @@ class CatfishWindow(Window):
if len(parts[0].strip()) > 0:
label = Gtk.Label.new(parts[0])
row.pack_start(label, False, False, 0)
- image = Gtk.Image.new_from_icon_name("emblem-system-symbolic", Gtk.IconSize.BUTTON)
+ image = Gtk.Image.new_from_icon_name("emblem-system-symbolic",
+ Gtk.IconSize.BUTTON)
image.set_property("use-fallback", True)
row.pack_start(image, False, False, 0)
if len(parts[1].strip()) > 0:
@@ -1040,7 +1042,8 @@ class CatfishWindow(Window):
fm = self.get_exo_preferred_file_manager()
return "thunar" in fm.lower()
- fm = subprocess.check_output(['xdg-mime','query','default', 'inode/directory'])
+ fm = subprocess.check_output(['xdg-mime', 'query', 'default',
+ 'inode/directory'])
fm = fm.decode("utf-8", errors="replace")
if "thunar" in fm.lower():
return True
@@ -1648,7 +1651,8 @@ class CatfishWindow(Window):
def get_thumbnail(self, path, mime_type=None):
"""Try to fetch a thumbnail."""
- thumb = self.thumbnailer.get_thumbnail(path, mime_type, self.show_thumbnail)
+ thumb = self.thumbnailer.get_thumbnail(path, mime_type,
+ self.show_thumbnail)
if thumb:
return thumb
return self.get_file_icon(path, mime_type)
diff --git a/catfish_lib/CatfishSettings.py b/catfish_lib/CatfishSettings.py
index 32a7993..275b0b3 100644
--- a/catfish_lib/CatfishSettings.py
+++ b/catfish_lib/CatfishSettings.py
@@ -95,7 +95,7 @@ class CatfishSettings:
except Exception:
pass
- if self.settings['use-headerbar'] == None:
+ if self.settings['use-headerbar'] is None:
current_desktop = self.get_current_desktop()
if current_desktop in ["budgie", "gnome", "pantheon"]:
self.settings['use-headerbar'] = True
@@ -111,7 +111,8 @@ class CatfishSettings:
write_file = open(self.settings_file, 'w')
for key in list(self.settings.keys()):
value = self.settings[key]
- if key == 'use-headerbar' and not self.headerbar_configured:
+ if key == 'use-headerbar' and \
+ not self.headerbar_configured:
continue
if isinstance(value, bool):
value = str(value).lower()
diff --git a/catfish_lib/Thumbnailer.py b/catfish_lib/Thumbnailer.py
index 2f1a7af..511fffa 100644
--- a/catfish_lib/Thumbnailer.py
+++ b/catfish_lib/Thumbnailer.py
@@ -24,6 +24,7 @@ from gi.repository import GLib, Gio, GdkPixbuf
from . catfishconfig import get_version
+
class Thumbnailer:
def __init__(self):
@@ -69,8 +70,8 @@ class Thumbnailer:
return os.path.join(expected, faildir)
def _make_thumbnail_directory(self, path):
- # All the directories including the $XDG_CACHE_HOME/thumbnails directory
- # must have set their permissions to 700
+ # All the directories including the $XDG_CACHE_HOME/thumbnails
+ # directory must have set their permissions to 700
if os.path.exists(path):
return True
try:
@@ -84,10 +85,11 @@ class Thumbnailer:
# $XDG_CACHE_HOME/thumbnails/normal (128x128)
# $XDG_CACHE_HOME/thumbnails/large/ (256x256)
# $XDG_CACHE_HOME/thumbnails/fail/ (failed generation)
- # All the directories including the $XDG_CACHE_HOME/thumbnails directory
- # must have set their permissions to 700 (this means only the owner has read,
- # write and execute permissions, see "man chmod" for details). Similar,
- # all the files in the thumbnail directories should have set their permissions to 600.
+ # All the directories including the $XDG_CACHE_HOME/thumbnails
+ # directory must have set their permissions to 700 (this means
+ # only the owner has read, write and execute permissions, see
+ # "man chmod" for details). Similar, all the files in the thumbnail
+ # directories should have set their permissions to 600.
if not self._make_thumbnail_directory(self._get_normal_directory()):
return False
return True
@@ -132,9 +134,10 @@ class Thumbnailer:
def _touch(self, fname, mode=0o600, dir_fd=None, **kwargs):
flags = os.O_CREAT | os.O_APPEND
- with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
+ with os.fdopen(os.open(fname, flags=flags, mode=mode,
+ dir_fd=dir_fd)) as f:
os.utime(f.fileno() if os.utime in os.supports_fd else fname,
- dir_fd=None if os.supports_fd else dir_fd, **kwargs)
+ dir_fd=None if os.supports_fd else dir_fd, **kwargs)
def _get_attributes(self, filename):
gfile = Gio.File.new_for_path(filename)
@@ -157,7 +160,8 @@ class Thumbnailer:
try:
thumb_pb = GdkPixbuf.Pixbuf.new_from_file(thumbnail)
- thumb_pb.savev(thumbnail, "png", list(options.keys()), list(options.values()))
+ thumb_pb.savev(thumbnail, "png", list(options.keys()),
+ list(options.values()))
except GLib.GError:
pass
@@ -184,7 +188,8 @@ class Thumbnailer:
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()))
+ pixbuf.savev(thumbnail, "png", list(options.keys()),
+ list(options.values()))
os.chmod(thumbnail, 0o600)
return True
if pixbuf_w > pixbuf_h:
@@ -200,14 +205,15 @@ class Thumbnailer:
if thumb_pixbuf is None:
return False
options = self._get_attributes(filename)
- thumb_pixbuf.savev(thumbnail, "png", list(options.keys()), list(options.values()))
+ thumb_pixbuf.savev(thumbnail, "png", list(options.keys()),
+ list(options.values()))
os.chmod(thumbnail, 0o600)
return True
except Exception as e:
print("Exception: ", e)
return False
- def get_thumbnail(self, filename, mime_type = None, buildit = True):
+ def get_thumbnail(self, filename, mime_type=None, buildit=True):
thumb = self._get_normal_filename(filename)
if os.path.exists(thumb):
return thumb
@@ -225,7 +231,7 @@ class Thumbnailer:
if mime_type is None:
mime_type = self._get_mime_type(filename)
-
+
if mime_type.startswith('image'):
if mime_type in ["image/x-photoshop"]:
return False
@@ -240,4 +246,4 @@ class Thumbnailer:
return normal
else:
self._write_fail(filename)
- return False
\ No newline at end of file
+ return False
diff --git a/catfish_lib/Window.py b/catfish_lib/Window.py
index 4f78c3a..2d57a51 100644
--- a/catfish_lib/Window.py
+++ b/catfish_lib/Window.py
@@ -345,7 +345,7 @@ class Window(Gtk.Window):
return False
def on_catfish_window_size_allocate(self, widget, allocation):
- paned =self.builder.get_named_object("window.paned")
+ paned = self.builder.get_named_object("window.paned")
allocation = paned.get_allocation()
self.settings.set_setting('window-height', allocation.height)
self.settings.set_setting('window-width', allocation.width)
diff --git a/catfish_lib/helpers.py b/catfish_lib/helpers.py
index 9ef9bac..ef8c9df 100644
--- a/catfish_lib/helpers.py
+++ b/catfish_lib/helpers.py
@@ -22,11 +22,10 @@ import os
import sys
import gi
-gi.require_version('GLib', '2.0')
-gi.require_version('GObject', '2.0')
-gi.require_version('Gdk', '3.0')
-gi.require_version('Gtk', '3.0')
-
+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 . catfishconfig import get_data_file
diff --git a/po/catfish.pot b/po/catfish.pot
index ccd5baa..e2c706f 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: 2019-08-24 13:13-0400\n"
+"POT-Creation-Date: 2019-08-24 13:31-0400\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"
@@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
#: ../org.xfce.Catfish.desktop.in.h:1 ../data/ui/CatfishWindow.ui.h:28
-#: ../catfish/CatfishWindow.py:711
+#: ../catfish/CatfishWindow.py:713
msgid "Catfish File Search"
msgstr ""
@@ -137,11 +137,11 @@ msgstr ""
msgid "File Type"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1253
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1256
msgid "Modified"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1700
+#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1704
msgid "Results will be displayed as soon as they are found."
msgstr ""
@@ -265,160 +265,160 @@ msgstr ""
#. Translators: this text is displayed next to
#. a filename that is not utf-8 encoded.
-#: ../catfish/CatfishWindow.py:100
+#: ../catfish/CatfishWindow.py:99
#, python-format
msgid "%s (invalid encoding)"
msgstr ""
-#: ../catfish/CatfishWindow.py:256
+#: ../catfish/CatfishWindow.py:255
msgid "Unknown"
msgstr ""
-#: ../catfish/CatfishWindow.py:260
+#: ../catfish/CatfishWindow.py:259
msgid "Never"
msgstr ""
-#: ../catfish/CatfishWindow.py:336
+#: ../catfish/CatfishWindow.py:337
#, python-format
msgid ""
"Enter your query above to find your files\n"
"or click the %s icon for more options."
msgstr ""
-#: ../catfish/CatfishWindow.py:679
+#: ../catfish/CatfishWindow.py:681
msgid "An error occurred while updating the database."
msgstr ""
-#: ../catfish/CatfishWindow.py:681
+#: ../catfish/CatfishWindow.py:683
msgid "Authentication failed."
msgstr ""
-#: ../catfish/CatfishWindow.py:687
+#: ../catfish/CatfishWindow.py:689
msgid "Authentication cancelled."
msgstr ""
-#: ../catfish/CatfishWindow.py:693
+#: ../catfish/CatfishWindow.py:695
msgid "Search database updated successfully."
msgstr ""
#. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:768
+#: ../catfish/CatfishWindow.py:770
msgid "Updating..."
msgstr ""
-#: ../catfish/CatfishWindow.py:802
+#: ../catfish/CatfishWindow.py:804
msgid "Stop Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:803
+#: ../catfish/CatfishWindow.py:805
msgid ""
"Search is in progress...\n"
"Press the cancel button or the Escape key to stop."
msgstr ""
-#: ../catfish/CatfishWindow.py:812
+#: ../catfish/CatfishWindow.py:814
msgid "Begin Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:1073
+#: ../catfish/CatfishWindow.py:1076
#, python-format
msgid "\"%s\" could not be opened."
msgstr ""
-#: ../catfish/CatfishWindow.py:1125
+#: ../catfish/CatfishWindow.py:1128
#, python-format
msgid "\"%s\" could not be saved."
msgstr ""
-#: ../catfish/CatfishWindow.py:1142
+#: ../catfish/CatfishWindow.py:1145
#, python-format
msgid "\"%s\" could not be deleted."
msgstr ""
-#: ../catfish/CatfishWindow.py:1182
+#: ../catfish/CatfishWindow.py:1185
#, python-format
msgid "Save \"%s\" as..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1217
+#: ../catfish/CatfishWindow.py:1220
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete \"%s\"?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1221
+#: ../catfish/CatfishWindow.py:1224
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete the %i selected files?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1224
+#: ../catfish/CatfishWindow.py:1227
msgid "If you delete a file, it is permanently lost."
msgstr ""
-#: ../catfish/CatfishWindow.py:1247
+#: ../catfish/CatfishWindow.py:1250
msgid "Filename"
msgstr ""
-#: ../catfish/CatfishWindow.py:1249
+#: ../catfish/CatfishWindow.py:1252
msgid "Size"
msgstr ""
-#: ../catfish/CatfishWindow.py:1251
+#: ../catfish/CatfishWindow.py:1254
msgid "Location"
msgstr ""
-#: ../catfish/CatfishWindow.py:1263
+#: ../catfish/CatfishWindow.py:1266
msgid "Preview"
msgstr ""
-#: ../catfish/CatfishWindow.py:1271
+#: ../catfish/CatfishWindow.py:1274
msgid "Details"
msgstr ""
-#: ../catfish/CatfishWindow.py:1490
+#: ../catfish/CatfishWindow.py:1493
msgid "Today"
msgstr ""
-#: ../catfish/CatfishWindow.py:1492
+#: ../catfish/CatfishWindow.py:1495
msgid "Yesterday"
msgstr ""
-#: ../catfish/CatfishWindow.py:1573
+#: ../catfish/CatfishWindow.py:1576
msgid "No files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1575
+#: ../catfish/CatfishWindow.py:1578
msgid ""
"Try making your search less specific\n"
"or try another directory."
msgstr ""
-#: ../catfish/CatfishWindow.py:1582
+#: ../catfish/CatfishWindow.py:1585
msgid "1 file found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1584
+#: ../catfish/CatfishWindow.py:1587
#, python-format
msgid "%i files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1590
+#: ../catfish/CatfishWindow.py:1593
msgid "bytes"
msgstr ""
-#: ../catfish/CatfishWindow.py:1698 ../catfish/CatfishWindow.py:1708
+#: ../catfish/CatfishWindow.py:1702 ../catfish/CatfishWindow.py:1712
msgid "Searching..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1706
+#: ../catfish/CatfishWindow.py:1710
#, python-format
msgid "Searching for \"%s\""
msgstr ""
-#: ../catfish/CatfishWindow.py:1790
+#: ../catfish/CatfishWindow.py:1794
#, python-format
msgid "Search results for \"%s\""
msgstr ""
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list