57413f8
From 99578c5d7ce9a6ed952da292a2ed8467dc5c85d5 Mon Sep 17 00:00:00 2001
57413f8
From: Matej Habrnal <mhabrnal@redhat.com>
57413f8
Date: Thu, 31 May 2018 15:05:15 +0200
57413f8
Subject: [PATCH] pylint: fix some pylint warnings
57413f8
57413f8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
57413f8
---
57413f8
 pylintrc                             |  2 +-
57413f8
 src/gnome_abrt/application.py        |  2 +-
57413f8
 src/gnome_abrt/dbus_problems.py      |  4 +---
57413f8
 src/gnome_abrt/directory_problems.py |  4 ++--
57413f8
 src/gnome_abrt/problems.py           | 32 +++++++++-----------------------
57413f8
 src/gnome_abrt/views.py              |  8 ++------
57413f8
 6 files changed, 16 insertions(+), 36 deletions(-)
57413f8
57413f8
diff --git a/pylintrc b/pylintrc
57413f8
index 934d7c0..0dc1c8e 100644
57413f8
--- a/pylintrc
57413f8
+++ b/pylintrc
57413f8
@@ -155,7 +155,7 @@ ignore-imports=no
57413f8
 [FORMAT]
57413f8
 
57413f8
 # Maximum number of characters on a single line.
57413f8
-max-line-length=80
57413f8
+max-line-length=120
57413f8
 
57413f8
 # Maximum number of lines in a module
57413f8
 max-module-lines=1000
57413f8
diff --git a/src/gnome_abrt/application.py b/src/gnome_abrt/application.py
57413f8
index 3504b03..927262a 100644
57413f8
--- a/src/gnome_abrt/application.py
57413f8
+++ b/src/gnome_abrt/application.py
57413f8
@@ -16,7 +16,7 @@
57413f8
 ## Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335  USA
57413f8
 
57413f8
 import os
57413f8
-import gnome_abrt.wrappers as wrappers
57413f8
+from gnome_abrt import wrappers
57413f8
 
57413f8
 class Application(object):
57413f8
 
57413f8
diff --git a/src/gnome_abrt/dbus_problems.py b/src/gnome_abrt/dbus_problems.py
57413f8
index 89f092e..d6574aa 100644
57413f8
--- a/src/gnome_abrt/dbus_problems.py
57413f8
+++ b/src/gnome_abrt/dbus_problems.py
57413f8
@@ -22,9 +22,7 @@ import traceback
57413f8
 import dbus
57413f8
 from dbus.mainloop.glib import DBusGMainLoop
57413f8
 
57413f8
-import gnome_abrt.problems as problems
57413f8
-import gnome_abrt.config as config
57413f8
-import gnome_abrt.errors as errors
57413f8
+from gnome_abrt import problems, config, errors
57413f8
 from gnome_abrt.l10n import _
57413f8
 
57413f8
 BUS_NAME = 'org.freedesktop.problems'
57413f8
diff --git a/src/gnome_abrt/directory_problems.py b/src/gnome_abrt/directory_problems.py
57413f8
index 02a06ed..3ec7fe5 100644
57413f8
--- a/src/gnome_abrt/directory_problems.py
57413f8
+++ b/src/gnome_abrt/directory_problems.py
57413f8
@@ -30,8 +30,8 @@ import pyinotify
57413f8
 from pyinotify import WatchManager, Notifier, ProcessEvent
57413f8
 
57413f8
 # gnome-abrt
57413f8
-import gnome_abrt.problems as problems
57413f8
-import gnome_abrt.errors as errors
57413f8
+from gnome_abrt import problems
57413f8
+from gnome_abrt import errors
57413f8
 from gnome_abrt.l10n import _
57413f8
 
57413f8
 class INOTIFYGlibSource(GLib.Source):
57413f8
diff --git a/src/gnome_abrt/problems.py b/src/gnome_abrt/problems.py
57413f8
index fbde9ac..05a3fa7 100644
57413f8
--- a/src/gnome_abrt/problems.py
57413f8
+++ b/src/gnome_abrt/problems.py
57413f8
@@ -17,6 +17,7 @@
57413f8
 
57413f8
 import datetime
57413f8
 import logging
57413f8
+import re
57413f8
 
57413f8
 # gnome-abrt
57413f8
 import gnome_abrt.url
57413f8
@@ -279,6 +280,7 @@ class Problem(object):
57413f8
 
57413f8
     def get_submission(self):
57413f8
         if not self.submission:
57413f8
+            reg = re.compile(r'^(?P<pfx>.*):\s*(?P<typ>\S*)=(?P<data>.*)')
57413f8
             self.submission = []
57413f8
             if self['reported_to']:
57413f8
                 # Most common type of line in reported_to file
57413f8
@@ -287,30 +289,14 @@ class Problem(object):
57413f8
                     if not line:
57413f8
                         continue
57413f8
 
57413f8
-                    pfx_lst = []
57413f8
-                    i = 0
57413f8
-                    for i in range(0, len(line)):
57413f8
-                        if line[i] == ':':
57413f8
-                            break
57413f8
-                        pfx_lst.append(line[i])
57413f8
-
57413f8
-                    pfx = ''.join(pfx_lst)
57413f8
-                    i += 1
57413f8
-
57413f8
-                    for i in range(i, len(line)):
57413f8
-                        if line[i] != ' ':
57413f8
-                            break
57413f8
-
57413f8
-                    typ_lst = []
57413f8
-                    for i in range(i, len(line)):
57413f8
-                        if line[i] == '=':
57413f8
-                            break
57413f8
-                        typ_lst.append(line[i])
57413f8
-
57413f8
-                    typ = ''.join(typ_lst)
57413f8
-                    i += 1
57413f8
+                    parsed = reg.match(line)
57413f8
+                    if parsed:
57413f8
+                        pfx = parsed.group('pfx')
57413f8
+                        typ = parsed.group('typ')
57413f8
+                        data = parsed.group('data')
57413f8
+                    else:
57413f8
+                        continue
57413f8
 
57413f8
-                    data = line[i:]
57413f8
                     sbm = next((s for s in self.submission
57413f8
                                 if s.rtype == typ and s.name == pfx), None)
57413f8
 
57413f8
diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py
57413f8
index ec7b211..1b62515 100644
57413f8
--- a/src/gnome_abrt/views.py
57413f8
+++ b/src/gnome_abrt/views.py
57413f8
@@ -40,12 +40,7 @@ from gi.repository import GLib
57413f8
 
57413f8
 import humanize
57413f8
 
57413f8
-import gnome_abrt.problems as problems
57413f8
-import gnome_abrt.config as config
57413f8
-import gnome_abrt.wrappers as wrappers
57413f8
-import gnome_abrt.errors as errors
57413f8
-import gnome_abrt.desktop as desktop
57413f8
-from gnome_abrt import GNOME_ABRT_UI_DIR
57413f8
+from gnome_abrt import GNOME_ABRT_UI_DIR, problems, config, wrappers, errors, desktop
57413f8
 from gnome_abrt.tools import fancydate, smart_truncate, load_icon
57413f8
 from gnome_abrt.tools import set_icon_from_pixbuf_with_scale
57413f8
 from gnome_abrt.l10n import _, C_, GETTEXT_PROGNAME
57413f8
@@ -1075,6 +1070,7 @@ _("This problem has been reported, but a Bugzilla ticket has not"
57413f8
                     self._builder.lb_problems.select_row(problem_row)
57413f8
                     self._builder.menu_problem_item.popup(None, None,
57413f8
                             None, None, data.button, data.time)
57413f8
+        return None
57413f8
 
57413f8
     def get_box_header_left_offset(self):
57413f8
         # Returns the offset of box_header_left relative to the main paned
57413f8
-- 
57413f8
2.13.6
57413f8