[Pkg-privacy-commits] [mat] 60/68: Fix some pep8-related issues

Sascha Steinbiss sascha at steinbiss.name
Sun Jan 3 12:32:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository mat.

commit 3696b59badfef2438a3df1755868b2aeeb443b87
Author: jvoisin <julien.voisin at dustri.org>
Date:   Wed Dec 30 17:15:23 2015 +0100

    Fix some pep8-related issues
---
 libmat/archive.py        |  5 +++++
 libmat/mat.py            |  4 ++++
 mat                      |  6 +++---
 mat-gui                  | 24 +++++++++++++-----------
 nautilus/nautilus-mat.py | 11 +++++++++--
 setup.py                 |  1 +
 test/clitest.py          |  4 +++-
 test/test.py             | 21 +++++++++++++--------
 8 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/libmat/archive.py b/libmat/archive.py
index 61028ef..a662e61 100644
--- a/libmat/archive.py
+++ b/libmat/archive.py
@@ -47,6 +47,11 @@ class GenericArchiveStripper(parser.GenericParser):
         """
         return self.is_clean(list_unsupported=True)
 
+    def remove_all(self):
+        """ Virtual method to remove all compromising fields
+        """
+        raise NotImplementedError
+
 
 class ZipStripper(GenericArchiveStripper):
     """ Represent a zip file
diff --git a/libmat/mat.py b/libmat/mat.py
index e84c717..d397334 100644
--- a/libmat/mat.py
+++ b/libmat/mat.py
@@ -84,6 +84,8 @@ class XMLParser(xml.sax.handler.ContentHandler):  # pragma: no cover
 
     def startElement(self, name, attrs):
         """ Called when entering into xml tag
+        :param attrs: Attributes of the `nam` xml tag
+        :param name: Name of the xml tag
         """
         self.between = True
         self.key = name
@@ -91,6 +93,7 @@ class XMLParser(xml.sax.handler.ContentHandler):  # pragma: no cover
 
     def endElement(self, name):
         """ Called when exiting a xml tag
+        :param name: name of the element
         """
         if name == 'format':  # leaving a fileformat section
             self.list.append(self.dict.copy())
@@ -102,6 +105,7 @@ class XMLParser(xml.sax.handler.ContentHandler):  # pragma: no cover
 
     def characters(self, characters):
         """ Concatenate the content between opening and closing tags
+        :param characters: content of the tag
         """
         if self.between:
             self.content += characters
diff --git a/mat b/mat
index 4b6624e..64dccc4 100755
--- a/mat
+++ b/mat
@@ -117,9 +117,9 @@ def main():
     argparser = create_arg_parser()
     args = argparser.parse_args()
 
-    #show help if: neiter list nor file argument given; no argument at
-    #all given or the list argument mixed with some other argument given
-    if (not args.list and not args.files) or (not len(sys.argv) > 1) or (args.list and len(sys.argv) > 2):
+    # show help if: neither list nor file argument given; no argument at
+    # all given or the list argument mixed with some other argument given
+    if not (args.list or args.files) or (not sys.argv) or (args.list and len(sys.argv) > 2):
         argparser.print_help()
         sys.exit(2)
 
diff --git a/mat-gui b/mat-gui
index 238fdd7..cd03345 100755
--- a/mat-gui
+++ b/mat-gui
@@ -31,7 +31,7 @@ class CFile(GObject.Object):
     """
 
     def __init__(self, filename, **kwargs):
-        self.file = mat.create_class_file(filename, 0, **kwargs)
+        self.file = mat.create_class_file(filename, False, **kwargs)
 
 
 class GUI(object):
@@ -160,15 +160,15 @@ class GUI(object):
         """ Popup that display on double-click
             metadata from a file
         """
-        metadataPopupListStore = self.builder.get_object('MetadataPopupListStore')
-        metadataPopupListStore.clear()
+        metadatapopupliststore = self.builder.get_object('MetadataPopupListStore')
+        metadatapopupliststore.clear()
         if self.liststore[row][0].file.is_clean():
             self.liststore[row][2] = _('Clean')
-            metadataPopupListStore.append([_('No metadata found'), ''])
+            metadatapopupliststore.append([_('No metadata found'), ''])
         else:
             self.liststore[row][2] = _('Dirty')
             for i, j in self.liststore[row][0].file.get_meta().iteritems():
-                metadataPopupListStore.append([i, j])
+                metadatapopupliststore.append([i, j])
 
         popup_metadata = self.builder.get_object('MetadataPopup')
         title = self.liststore[row][0].file.basename
@@ -284,8 +284,8 @@ non-anonymised) file to output archive'))
         iterator = self.treeview.get_selection().get_selected_rows()[1]
         if not iterator:  # if nothing is selected : select everything
             iterator = range(len(self.liststore))
-        task = func(iterator)  # launch func() in an asynchronous way
-        GLib.idle_add(task.next)
+        sync_task = func(iterator)  # launch func() in an asynchronous way
+        GLib.idle_add(sync_task.next)
 
     def __invert(self, button, name):
         """ Invert a preference state """
@@ -295,7 +295,9 @@ non-anonymised) file to output archive'))
             self.add2archive = not self.add2archive
 
     def populate(self, filenames):
-        """ Append selected files by add_file to the self.liststore """
+        """ Append selected files by add_file to the self.liststore
+        :param filenames: selected files
+        """
         not_supported = []
         for filename in filenames:  # filenames : all selected files/folders
             if os.path.isdir(filename):  # if "filename" is a directory
@@ -343,10 +345,10 @@ non-anonymised) file to output archive'))
         vbox.pack_start(treeview, True, True, 0)
 
         # Create columns
-        rendererText = Gtk.CellRendererText()
-        column = Gtk.TreeViewColumn(_('Filename'), rendererText, text=0)
+        renderertext = Gtk.CellRendererText()
+        column = Gtk.TreeViewColumn(_('Filename'), renderertext, text=0)
         treeview.append_column(column)
-        column = Gtk.TreeViewColumn(_('Reason'), rendererText, text=1)
+        column = Gtk.TreeViewColumn(_('Reason'), renderertext, text=1)
         treeview.append_column(column)
 
         dialog.show_all()
diff --git a/nautilus/nautilus-mat.py b/nautilus/nautilus-mat.py
index 938e692..0974bef 100644
--- a/nautilus/nautilus-mat.py
+++ b/nautilus/nautilus-mat.py
@@ -24,6 +24,7 @@ import libmat.strippers
 
 class MatExtension(GObject.GObject, Nautilus.MenuProvider):
     """ A nautilus extension, acting as a frontend to MAT, to clean metadata."""
+
     def __init__(self):
         logging.debug("nautilus-mat: initialising")
 
@@ -58,7 +59,10 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider):
 
     @staticmethod
     def show_message(message, msg_type=Gtk.MessageType.INFO):
-        """ Helper function to show a message in a popup """
+        """ Helper function to show a message in a popup
+        :param msg_type: Type of the message to display
+        :param message: Message to display
+        """
         dialog = Gtk.MessageDialog(parent=None,
                                    flags=Gtk.DialogFlags.MODAL,
                                    type=msg_type,
@@ -69,7 +73,10 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider):
         return ret
 
     def menu_activate_cb(self, menu, current_file):
-        """ Callback function, used to clean the file """
+        """ Callback function, used to clean the file
+        :param current_file: Name of the selected file
+        :param menu: Menu id from which the callback was activated. Unused.
+        """
         if file.is_gone():
             return
 
diff --git a/setup.py b/setup.py
index ad798d7..fdee3ac 100755
--- a/setup.py
+++ b/setup.py
@@ -16,6 +16,7 @@ if os.path.exists('MANIFEST'):
 
 class PyTest(Command):
     user_options = []
+
     def initialize_options(self):
         pass
 
diff --git a/test/clitest.py b/test/clitest.py
index e186531..884655f 100644
--- a/test/clitest.py
+++ b/test/clitest.py
@@ -136,10 +136,11 @@ class TestUnsupported(test.MATTest):
         tar.close()
         proc = subprocess.Popen(['mat', tarpath], stdout=subprocess.PIPE)
         stdout, _ = proc.communicate()
-        self.assertTrue('It contains unsupported filetypes:' \
+        self.assertTrue('It contains unsupported filetypes:'
                         '\n- libtest.py\n- test.py\n- clitest.py\n'
                         in str(stdout))
 
+
 class TestHelp(test.MATTest):
     """ Test the different ways to trigger help """
     def test_dash_h(self):
@@ -164,6 +165,7 @@ class TestHelp(test.MATTest):
         _, stderr = proc.communicate()
         self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr)
 
+
 def get_tests():
     """ Return every clitests"""
     suite = unittest.TestSuite()
diff --git a/test/test.py b/test/test.py
index fbbdcf4..6886c1f 100644
--- a/test/test.py
+++ b/test/test.py
@@ -14,6 +14,7 @@ import glob
 import sys
 import tempfile
 import unittest
+import subprocess
 
 VERBOSITY = 15
 
@@ -27,6 +28,7 @@ FILE_LIST = zip(clean, dirty)
 try:  # PDF render processing
     import cairo
     import gi
+
     gi.require_version('Poppler', '0.18')
     from gi.repository import Poppler
     import pdfrw
@@ -42,9 +44,10 @@ except ImportError:
 
 try:  # exiftool
     subprocess.check_output(['exiftool', '-ver'])
-except:
+except OSError:
     FILE_LIST.remove(('clean é.tif', 'dirty é.tif'))
 
+
 class MATTest(unittest.TestCase):
     """
         Parent class of all test-functions
@@ -84,26 +87,28 @@ def run_all_tests():
     """
     import clitest
     import libtest
-    SUITE = unittest.TestSuite()
-    SUITE.addTests(clitest.get_tests())
-    SUITE.addTests(libtest.get_tests())
+    suite = unittest.TestSuite()
+    suite.addTests(clitest.get_tests())
+    suite.addTests(libtest.get_tests())
+
+    return unittest.TextTestRunner(verbosity=VERBOSITY).run(suite).wasSuccessful()
 
-    return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
 
 def set_local():
-    ''' Monkey patch pathes to run the testsuite on the _local_
+    """ Monkey patch pathes to run the testsuite on the _local_
     version of MAT. See `run_all_tests` for more information about
     what pathes we're changing and why.
-    '''
+    """
     os.environ['PATH'] = '..:' + os.environ['PATH']
     sys.path.append('..')
 
+
 if __name__ == '__main__':
     import argparse
 
     parser = argparse.ArgumentParser(description='MAT testsuite')
     parser.add_argument('-s', '--system', action='store_true',
-            help='Test the system-wide version of mat')
+                        help='Test the system-wide version of mat')
 
     if parser.parse_args().system is False:
         set_local()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/mat.git



More information about the Pkg-privacy-commits mailing list