[meld] Code cleanup to get more close to PEP8



commit cbcfc000d3d25fb9605ed2a3240f85036a9acf80
Author: David Rabel <David Rabel NoreSoft com>
Date:   Wed Oct 21 16:05:51 2015 +0200

    Code cleanup to get more close to PEP8
    
    Mostly "E501 line too long".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756911

 meld/build_helpers.py         |   14 +++++++++-----
 meld/diffutil.py              |    8 ++++----
 meld/gutterrendererchunk.py   |    2 +-
 meld/linkmap.py               |    3 ++-
 meld/matchers.py              |    2 +-
 meld/meldbuffer.py            |    2 +-
 meld/meldwindow.py            |   11 +++++++----
 meld/merge.py                 |    2 +-
 meld/misc.py                  |    4 ++--
 meld/recent.py                |    6 ++++--
 meld/tree.py                  |    4 ++--
 meld/ui/emblemcellrenderer.py |    5 +++--
 meld/ui/notebooklabel.py      |    9 ++++++---
 meld/ui/statusbar.py          |    3 ++-
 meld/undo.py                  |    3 ++-
 meld/vc/bzr.py                |    1 -
 meld/vc/svn.py                |    2 +-
 setup_win32.py                |    4 ++--
 test/test_matchers.py         |    6 ++++--
 19 files changed, 54 insertions(+), 37 deletions(-)
---
diff --git a/meld/build_helpers.py b/meld/build_helpers.py
index 69ad5bf..8e65cd0 100644
--- a/meld/build_helpers.py
+++ b/meld/build_helpers.py
@@ -139,10 +139,12 @@ class build_help(distutils.cmd.Command):
                 msgfmt = ['msgfmt', po_file, '-o', mo_file]
                 self.spawn(msgfmt)
                 for page in self.C_PAGES:
-                    itstool = ['itstool', '-m', mo_file, '-o', build_path, page]
+                    itstool = [
+                        'itstool', '-m', mo_file, '-o', build_path, page]
                     self.spawn(itstool)
                 for extra in self.C_EXTRA:
-                    extra_path = os.path.join(build_path, os.path.basename(extra))
+                    extra_path = os.path.join(
+                        build_path, os.path.basename(extra))
                     if os.path.exists(extra_path):
                         os.unlink(extra_path)
                     os.symlink(os.path.relpath(extra, source_path), extra_path)
@@ -154,7 +156,8 @@ class build_help(distutils.cmd.Command):
             path_help = os.path.join('share', 'help', lang, name)
             path_figures = os.path.join(path_help, 'figures')
             data_files.append((path_help, xml_files + mallard_files))
-            data_files.append((path_figures, glob.glob('%s/figures/*.png' % build_path)))
+            data_files.append(
+                (path_figures, glob.glob('%s/figures/*.png' % build_path)))
 
         return data_files
 
@@ -201,7 +204,8 @@ class build_icons(distutils.cmd.Command):
                 for category in glob.glob(os.path.join(size, "*")):
                     icons = (glob.glob(os.path.join(category, "*.png")) +
                              glob.glob(os.path.join(category, "*.svg")))
-                    icons = [icon for icon in icons if not os.path.islink(icon)]
+                    icons = [
+                        icon for icon in icons if not os.path.islink(icon)]
                     if not icons:
                         continue
                     data_files.append(("%s/%s/%s/%s" %
@@ -262,7 +266,7 @@ class build_i18n(distutils.cmd.Command):
         max_po_mtime = 0
         for po_file in glob.glob("%s/*.po" % self.po_dir):
             lang = os.path.basename(po_file[:-3])
-            if selected_languages and not lang in selected_languages:
+            if selected_languages and lang not in selected_languages:
                 continue
             mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
             mo_file = os.path.join(mo_dir, "%s.mo" % self.domain)
diff --git a/meld/diffutil.py b/meld/diffutil.py
index 294d8b0..2475cf2 100644
--- a/meld/diffutil.py
+++ b/meld/diffutil.py
@@ -63,7 +63,7 @@ class Differ(GObject.GObject):
 
     __gsignals__ = {
         'diffs-changed': (GObject.SignalFlags.RUN_FIRST, None,
-                                                    (object,)),
+                          (object,)),
     }
 
     _matcher = MyersSequenceMatcher
@@ -296,14 +296,14 @@ class Differ(GObject.GObject):
 
         def offset(c, o1, o2):
             return DiffChunk._make((c[0], c[1] + o1, c[2] + o1,
-                                          c[3] + o2, c[4] + o2))
+                                    c[3] + o2, c[4] + o2))
 
         newdiffs = self._matcher(None, lines1, linesx).get_difference_opcodes()
         newdiffs = [offset(c, range1[0], rangex[0]) for c in newdiffs]
 
         if hiidx < len(self.diffs[which]):
-            offset_diffs = [offset(c, lines_added[1], lines_added[x]) for c
-                                                  in self.diffs[which][hiidx:]]
+            offset_diffs = [offset(c, lines_added[1], lines_added[x])
+                            for c in self.diffs[which][hiidx:]]
             self.diffs[which][hiidx:] = offset_diffs
         self.diffs[which][loidx:hiidx] = newdiffs
 
diff --git a/meld/gutterrendererchunk.py b/meld/gutterrendererchunk.py
index 9b12522..a5d3cae 100644
--- a/meld/gutterrendererchunk.py
+++ b/meld/gutterrendererchunk.py
@@ -39,7 +39,7 @@ class MeldGutterRenderer(object):
 
     def on_setting_changed(self, meldsettings, key):
         if key == 'style-scheme':
-            #meldsettings.style_scheme
+            # meldsettings.style_scheme
             self.fill_colors, self.line_colors = get_common_theme()
 
     def draw_chunks(
diff --git a/meld/linkmap.py b/meld/linkmap.py
index f755b8d..f7c11f0 100644
--- a/meld/linkmap.py
+++ b/meld/linkmap.py
@@ -56,7 +56,8 @@ class LinkMap(Gtk.DrawingArea):
         allocation = self.get_allocation()
 
         pix_start = [t.get_visible_rect().y for t in self.views]
-        y_offset = [t.translate_coordinates(self, 0, 0)[1] + 1 for t in self.views]
+        y_offset = [
+            t.translate_coordinates(self, 0, 0)[1] + 1 for t in self.views]
 
         clip_y = min(y_offset) - 1
         clip_height = max(t.get_visible_rect().height for t in self.views) + 2
diff --git a/meld/matchers.py b/meld/matchers.py
index 99c7e36..af51fa9 100644
--- a/meld/matchers.py
+++ b/meld/matchers.py
@@ -428,7 +428,7 @@ class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):
                     tag = 'insert'
                 if tag:
                     opcodes.append((tag, i, ai, j, bj))
-                i, j = ai+size, bj+size
+                i, j = ai + size, bj + size
                 # the list of matching blocks is terminated by a
                 # sentinel with size 0
                 if size:
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 9c89999..0a30ee1 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -134,7 +134,7 @@ class MeldBufferData(GObject.GObject):
 
     @property
     def label(self):
-        #TRANSLATORS: This is the label of a new, currently-unnamed file.
+        # TRANSLATORS: This is the label of a new, currently-unnamed file.
         return self._label or _(u"<unnamed>")
 
     @label.setter
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 0eb7459..62fdef6 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -138,8 +138,9 @@ class MeldWindow(gnomeglade.Component):
         self.actiongroup.add_actions(actions)
         self.actiongroup.add_toggle_actions(toggleactions)
 
-        recent_action = Gtk.RecentAction(name="Recent",  label=_("Open Recent"),
-                                         tooltip=_("Open recent files"), stock_id=None)
+        recent_action = Gtk.RecentAction(
+            name="Recent",  label=_("Open Recent"),
+            tooltip=_("Open recent files"), stock_id=None)
         recent_action.set_show_private(True)
         recent_action.set_filter(recent_comparisons.recent_filter)
         recent_action.set_sort_type(Gtk.RecentSortType.MRU)
@@ -554,7 +555,9 @@ class MeldWindow(gnomeglade.Component):
             label = label.replace("_", "__")
             name = "SwitchTab%d" % i
             tooltip = _("Switch to this tab")
-            action = Gtk.RadioAction(name=name, label=label, tooltip=tooltip, stock_id=None, value=i)
+            action = Gtk.RadioAction(
+                name=name, label=label, tooltip=tooltip,
+                stock_id=None, value=i)
             action.join_group(group)
             group = action
             action.set_active(current_page == i)
@@ -650,7 +653,7 @@ class MeldWindow(gnomeglade.Component):
             doc.on_button_diff_clicked(None)
         return doc
 
-    def append_filediff(self, files,  merge_output=None, meta=None):
+    def append_filediff(self, files, merge_output=None, meta=None):
         assert len(files) in (1, 2, 3)
         doc = filediff.FileDiff(len(files))
         self._append_page(doc, "text-x-generic")
diff --git a/meld/merge.py b/meld/merge.py
index e551288..9c454ed 100644
--- a/meld/merge.py
+++ b/meld/merge.py
@@ -20,7 +20,7 @@ from . import matchers
 class AutoMergeDiffer(diffutil.Differ):
 
     _matcher = matchers.MyersSequenceMatcher
-   # _matcher = PatienceSequenceMatcher
+    # _matcher = PatienceSequenceMatcher
 
     def __init__(self):
         diffutil.Differ.__init__(self)
diff --git a/meld/misc.py b/meld/misc.py
index 49b7940..8f9d4ee 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -413,7 +413,7 @@ def shell_to_regex(pat):
                 res += r'\['
             else:
                 stuff = pat[i:j]
-                i = j+1
+                i = j + 1
                 if stuff[0] == '!':
                     stuff = '^%s' % stuff[1:]
                 elif stuff[0] == '^':
@@ -426,7 +426,7 @@ def shell_to_regex(pat):
                 res += '\\{'
             else:
                 stuff = pat[i:j]
-                i = j+1
+                i = j + 1
                 res += '(%s)' % "|".join(
                     [shell_to_regex(p)[:-1] for p in stuff.split(",")]
                 )
diff --git a/meld/recent.py b/meld/recent.py
index 90db21a..abbd7f9 100644
--- a/meld/recent.py
+++ b/meld/recent.py
@@ -98,7 +98,8 @@ class RecentFiles(object):
         comparison_key = (comp_type, tuple(paths))
         paths = [unicodeify(p) for p in paths]
         if comparison_key in self._stored_comparisons:
-            gio_file = Gio.File.new_for_uri(self._stored_comparisons[comparison_key])
+            gio_file = Gio.File.new_for_uri(
+                self._stored_comparisons[comparison_key])
         else:
             recent_path = self._write_recent_file(comp_type, paths)
             gio_file = Gio.File.new_for_path(recent_path)
@@ -181,7 +182,8 @@ class RecentFiles(object):
 
         # Remove any comparison files that are not listed by RecentManager
         item_uris = [item.get_uri() for item in meld_items]
-        item_paths = [Gio.File.new_for_uri(uri).get_path() for uri in item_uris]
+        item_paths = [
+            Gio.File.new_for_uri(uri).get_path() for uri in item_uris]
         stored = [p for p in os.listdir(self.recent_path)
                   if p.endswith(self.recent_suffix)]
         for path in stored:
diff --git a/meld/tree.py b/meld/tree.py
index e71e878..519dbb7 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -151,7 +151,7 @@ class DiffTreeStore(Gtk.TreeStore):
         # if you try to give it a Gdk.Color property
         if tint:
             tint = tint.to_string() if tint else None
-        self.set_value(it, col_idx(COL_TINT,  pane), tint)
+        self.set_value(it, col_idx(COL_TINT, pane), tint)
 
         fg, style, weight, strike = self.text_attributes[state]
         self.set_value(it, col_idx(COL_FG, pane), fg)
@@ -196,7 +196,7 @@ class DiffTreeStore(Gtk.TreeStore):
                 while 1:
                     nc = self.iter_n_children(it)
                     if nc:
-                        it = self.iter_nth_child(it, nc-1)
+                        it = self.iter_nth_child(it, nc - 1)
                     else:
                         break
             else:
diff --git a/meld/ui/emblemcellrenderer.py b/meld/ui/emblemcellrenderer.py
index 900ded1..a924aae 100644
--- a/meld/ui/emblemcellrenderer.py
+++ b/meld/ui/emblemcellrenderer.py
@@ -91,8 +91,9 @@ class EmblemCellRenderer(Gtk.CellRenderer):
         if self._icon_name:
             pixbuf = self._get_pixbuf(self._icon_name, self._icon_size)
             context.set_operator(cairo.OPERATOR_SOURCE)
-            # Assumes square icons; may break if we don't get the requested size
-            height_offset = int((cell_area.height - pixbuf.get_height())/2)
+            # Assumes square icons; may break if we don't get the requested
+            # size
+            height_offset = int((cell_area.height - pixbuf.get_height()) / 2)
             Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, height_offset)
             context.rectangle(0, height_offset,
                               pixbuf.get_width(), pixbuf.get_height())
diff --git a/meld/ui/notebooklabel.py b/meld/ui/notebooklabel.py
index 76efb7d..60c7252 100644
--- a/meld/ui/notebooklabel.py
+++ b/meld/ui/notebooklabel.py
@@ -53,14 +53,17 @@ class NotebookLabel(Gtk.HBox):
         font_desc = self.get_style_context().get_font(Gtk.StateFlags.NORMAL)
         metrics = context.get_metrics(font_desc, context.get_language())
         char_width = metrics.get_approximate_char_width() / Pango.SCALE
-        valid, w, h = Gtk.icon_size_lookup_for_settings(self.get_settings(), Gtk.IconSize.MENU)
+        valid, w, h = Gtk.icon_size_lookup_for_settings(
+            self.get_settings(), Gtk.IconSize.MENU)
         # FIXME: PIXELS replacement
-        self.set_size_request(self.tab_width_in_chars * char_width + 2 * w, -1)
+        self.set_size_request(
+            self.tab_width_in_chars * char_width + 2 * w, -1)
 
         button = Gtk.Button()
         button.set_relief(Gtk.ReliefStyle.NONE)
         button.set_focus_on_click(False)
-        icon = Gio.ThemedIcon.new_with_default_fallbacks('window-close-symbolic')
+        icon = Gio.ThemedIcon.new_with_default_fallbacks(
+            'window-close-symbolic')
         image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.MENU)
         image.set_tooltip_text(_("Close tab"))
         button.add(image)
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index c4e40e8..feed0a5 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -41,7 +41,8 @@ class MeldStatusBar(Gtk.Statusbar):
         hbox.remove(label)
         hbox.pack_start(label, True, True, 0)
 
-        alignment = Gtk.Alignment.new(xalign=1.0, yalign=0.5, xscale=1.0, yscale=1.0)
+        alignment = Gtk.Alignment.new(
+            xalign=1.0, yalign=0.5, xscale=1.0, yscale=1.0)
         self.info_box = Gtk.HBox(homogeneous=False, spacing=12)
         self.info_box.show()
         alignment.add(self.info_box)
diff --git a/meld/undo.py b/meld/undo.py
index f8d7e0b..777c511 100644
--- a/meld/undo.py
+++ b/meld/undo.py
@@ -239,7 +239,8 @@ class UndoSequence(GObject.GObject):
     def abort_group(self):
         """Revert the sequence to the state before begin_group() was called.
 
-        Raises an AssertionError if there was no a matching call to begin_group().
+        Raises an AssertionError if there was no a matching call to
+        begin_group().
         """
         if self.busy:
             return
diff --git a/meld/vc/bzr.py b/meld/vc/bzr.py
index fe94332..9edd3a3 100644
--- a/meld/vc/bzr.py
+++ b/meld/vc/bzr.py
@@ -46,7 +46,6 @@ class Vc(_vc.Vc):
     CONFLICT_RE = "conflict in (.*)$"
     RENAMED_RE = u"^(.*) => (.*)$"
 
-
     commit_statuses = (
         _vc.STATE_MODIFIED, _vc.STATE_RENAMED, _vc.STATE_NEW, _vc.STATE_REMOVED
     )
diff --git a/meld/vc/svn.py b/meld/vc/svn.py
index 7449e78..68fb3d5 100644
--- a/meld/vc/svn.py
+++ b/meld/vc/svn.py
@@ -204,7 +204,7 @@ class Vc(_vc.Vc):
                     continue
                 if not os.path.isabs(path):
                     path = os.path.abspath(os.path.join(self.location, path))
-                for status in (e for e in entry.getchildren() \
+                for status in (e for e in entry.getchildren()
                                if e.tag == "wc-status"):
                     item = status.attrib["item"]
                     if item == "":
diff --git a/setup_win32.py b/setup_win32.py
index 36c509f..9e7f3bd 100644
--- a/setup_win32.py
+++ b/setup_win32.py
@@ -114,11 +114,11 @@ setup(
         'Topic :: Software Development',
         'Topic :: Software Development :: Version Control',
     ],
-    options = {
+    options={
         "build_exe": build_exe_options,
         "bdist_msi": bdist_msi_options,
     },
-    executables = [
+    executables=[
         Executable(
             "bin/meld",
             base="Win32GUI",
diff --git a/test/test_matchers.py b/test/test_matchers.py
index c76d708..955d420 100644
--- a/test/test_matchers.py
+++ b/test/test_matchers.py
@@ -2,6 +2,7 @@
 import unittest
 from meld import matchers
 
+
 class MatchersTests(unittest.TestCase):
 
     def testBasicMatcher(self):
@@ -40,7 +41,7 @@ class MatchersTests(unittest.TestCase):
         a = list('012a3456c789')
         b = list('0a3412b5678')
         r = [(0, 0, 1), (1, 4, 2), (6, 7, 2), (9, 9, 2), (12, 11, 0)]
-        matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,6)])
+        matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3, 6)])
         blocks = matcher.get_matching_blocks()
         self.assertEqual(blocks, r)
 
@@ -48,7 +49,8 @@ class MatchersTests(unittest.TestCase):
         a = list('012a3456c789')
         b = list('02a341b5678')
         r = [(0, 0, 1), (2, 1, 1), (3, 2, 3), (9, 9, 2), (12, 11, 0)]
-        matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,2), (8,6)])
+        matcher = matchers.SyncPointMyersSequenceMatcher(
+            None, a, b, [(3, 2), (8, 6)])
         blocks = matcher.get_matching_blocks()
         self.assertEqual(blocks, r)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]