[Xfce4-commits] [apps/catfish] 01/01: Simplify Python 2/3 code
noreply at xfce.org
noreply at xfce.org
Sat Aug 24 18:44:14 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 35d897f01cf8bc69d93a2f8b5ba144b7ccde3101
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sat Aug 24 12:44:08 2019 -0400
Simplify Python 2/3 code
---
catfish/CatfishWindow.py | 26 +++++++----------
po/catfish.pot | 76 ++++++++++++++++++++++++------------------------
2 files changed, 49 insertions(+), 53 deletions(-)
diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index aecec5c..76e7c1f 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -57,6 +57,11 @@ if not helpers.check_gobject_version(3, 9, 1):
mimetypes.init()
+if helpers.check_python_version(3, 0):
+ def long(value):
+ return int(value)
+
+
def get_application_path(application_name):
for path in os.getenv('PATH').split(':'):
if os.path.isdir(path):
@@ -1461,10 +1466,7 @@ class CatfishWindow(Window):
def cell_data_func_filesize(self, column, cell_renderer,
tree_model, tree_iter, id):
"""File size cell display function."""
- if helpers.check_python_version(3, 0):
- size = int(tree_model.get_value(tree_iter, id))
- else:
- size = long(tree_model.get_value(tree_iter, id)) # noqa
+ size = long(tree_model.get_value(tree_iter, id))
filesize = self.format_size(size)
cell_renderer.set_property('text', filesize)
@@ -1675,11 +1677,11 @@ class CatfishWindow(Window):
return icon_name
return "text-x-generic"
- def python_three_size_sort_func(self, model, row1, row2, user_data):
+ def size_sort_func(self, model, row1, row2, user_data):
"""Sort function used in Python 3."""
sort_column = 2
- value1 = int(model.get_value(row1, sort_column))
- value2 = int(model.get_value(row2, sort_column))
+ value1 = long(model.get_value(row1, sort_column))
+ value2 = long(model.get_value(row2, sort_column))
if value1 < value2:
return -1
elif value1 == value2:
@@ -1722,8 +1724,7 @@ class CatfishWindow(Window):
self.results_filter = model.filter_new()
self.results_filter.set_visible_func(self.results_filter_func)
sort = Gtk.TreeModelSort(model=self.results_filter)
- if helpers.check_python_version(3, 0):
- sort.set_sort_func(2, self.python_three_size_sort_func, None)
+ sort.set_sort_func(2, self.size_sort_func, None)
self.treeview.set_model(sort)
sort.get_model().get_model().clear()
self.treeview.columns_autosize()
@@ -1749,12 +1750,7 @@ class CatfishWindow(Window):
filename not in results:
try:
path, name = os.path.split(filename)
-
- if helpers.check_python_version(3, 0):
- size = int(os.path.getsize(filename))
- else:
- size = long(os.path.getsize(filename)) # noqa
-
+ size = long(os.path.getsize(filename))
modified = os.path.getmtime(filename)
mimetype, override = self.guess_mimetype(filename)
diff --git a/po/catfish.pot b/po/catfish.pot
index df1bbe9..a20e639 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 07:35-0400\n"
+"POT-Creation-Date: 2019-08-24 12:40-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:707
+#: ../catfish/CatfishWindow.py:712
msgid "Catfish File Search"
msgstr ""
@@ -137,11 +137,11 @@ msgstr ""
msgid "File Type"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1249
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1254
msgid "Modified"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1700
+#: ../data/ui/CatfishWindow.ui.h:29 ../catfish/CatfishWindow.py:1702
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:95
+#: ../catfish/CatfishWindow.py:100
#, python-format
msgid "%s (invalid encoding)"
msgstr ""
-#: ../catfish/CatfishWindow.py:251
+#: ../catfish/CatfishWindow.py:256
msgid "Unknown"
msgstr ""
-#: ../catfish/CatfishWindow.py:255
+#: ../catfish/CatfishWindow.py:260
msgid "Never"
msgstr ""
-#: ../catfish/CatfishWindow.py:331
+#: ../catfish/CatfishWindow.py:336
#, python-format
msgid ""
"Enter your query above to find your files\n"
"or click the %s icon for more options."
msgstr ""
-#: ../catfish/CatfishWindow.py:675
+#: ../catfish/CatfishWindow.py:680
msgid "An error occurred while updating the database."
msgstr ""
-#: ../catfish/CatfishWindow.py:677
+#: ../catfish/CatfishWindow.py:682
msgid "Authentication failed."
msgstr ""
-#: ../catfish/CatfishWindow.py:683
+#: ../catfish/CatfishWindow.py:688
msgid "Authentication cancelled."
msgstr ""
-#: ../catfish/CatfishWindow.py:689
+#: ../catfish/CatfishWindow.py:694
msgid "Search database updated successfully."
msgstr ""
#. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:764
+#: ../catfish/CatfishWindow.py:769
msgid "Updating..."
msgstr ""
-#: ../catfish/CatfishWindow.py:798
+#: ../catfish/CatfishWindow.py:803
msgid "Stop Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:799
+#: ../catfish/CatfishWindow.py:804
msgid ""
"Search is in progress...\n"
"Press the cancel button or the Escape key to stop."
msgstr ""
-#: ../catfish/CatfishWindow.py:808
+#: ../catfish/CatfishWindow.py:813
msgid "Begin Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:1069
+#: ../catfish/CatfishWindow.py:1074
#, python-format
msgid "\"%s\" could not be opened."
msgstr ""
-#: ../catfish/CatfishWindow.py:1121
+#: ../catfish/CatfishWindow.py:1126
#, python-format
msgid "\"%s\" could not be saved."
msgstr ""
-#: ../catfish/CatfishWindow.py:1138
+#: ../catfish/CatfishWindow.py:1143
#, python-format
msgid "\"%s\" could not be deleted."
msgstr ""
-#: ../catfish/CatfishWindow.py:1178
+#: ../catfish/CatfishWindow.py:1183
#, python-format
msgid "Save \"%s\" as..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1213
+#: ../catfish/CatfishWindow.py:1218
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete \"%s\"?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1217
+#: ../catfish/CatfishWindow.py:1222
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete the %i selected files?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1220
+#: ../catfish/CatfishWindow.py:1225
msgid "If you delete a file, it is permanently lost."
msgstr ""
-#: ../catfish/CatfishWindow.py:1243
+#: ../catfish/CatfishWindow.py:1248
msgid "Filename"
msgstr ""
-#: ../catfish/CatfishWindow.py:1245
+#: ../catfish/CatfishWindow.py:1250
msgid "Size"
msgstr ""
-#: ../catfish/CatfishWindow.py:1247
+#: ../catfish/CatfishWindow.py:1252
msgid "Location"
msgstr ""
-#: ../catfish/CatfishWindow.py:1259
+#: ../catfish/CatfishWindow.py:1264
msgid "Preview"
msgstr ""
-#: ../catfish/CatfishWindow.py:1267
+#: ../catfish/CatfishWindow.py:1272
msgid "Details"
msgstr ""
-#: ../catfish/CatfishWindow.py:1490
+#: ../catfish/CatfishWindow.py:1492
msgid "Today"
msgstr ""
-#: ../catfish/CatfishWindow.py:1492
+#: ../catfish/CatfishWindow.py:1494
msgid "Yesterday"
msgstr ""
-#: ../catfish/CatfishWindow.py:1573
+#: ../catfish/CatfishWindow.py:1575
msgid "No files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1575
+#: ../catfish/CatfishWindow.py:1577
msgid ""
"Try making your search less specific\n"
"or try another directory."
msgstr ""
-#: ../catfish/CatfishWindow.py:1582
+#: ../catfish/CatfishWindow.py:1584
msgid "1 file found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1584
+#: ../catfish/CatfishWindow.py:1586
#, python-format
msgid "%i files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1590
+#: ../catfish/CatfishWindow.py:1592
msgid "bytes"
msgstr ""
-#: ../catfish/CatfishWindow.py:1698 ../catfish/CatfishWindow.py:1708
+#: ../catfish/CatfishWindow.py:1700 ../catfish/CatfishWindow.py:1710
msgid "Searching..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1706
+#: ../catfish/CatfishWindow.py:1708
#, python-format
msgid "Searching for \"%s\""
msgstr ""
-#: ../catfish/CatfishWindow.py:1796
+#: ../catfish/CatfishWindow.py:1792
#, 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