[qt] make pylint a little more happy

Related to #137588

  • remove unused imports
  • rename unused variables
  • use imports instead of globals
  • use itertools.imap instead of map
  • some PEP8
  • do not overwrite builtins LookupError
authorAlain Leufroy <alain@leufroy.fr>
changeset5a8f7675edf4
branchdefault
phasepublic
hiddenno
parent revision#e4dadbf7a05a [qt] fix typo ``to_unicode`` -> ``tounicode``
child revision#970df51bfd0e [qt] refactorize checking of column names from user config
files modified by this revision
hgviewlib/qt4/hgfileview.py
# HG changeset patch
# User Alain Leufroy <alain@leufroy.fr>
# Date 1370639265 -7200
# Fri Jun 07 23:07:45 2013 +0200
# Node ID 5a8f7675edf467b9e2cbb14395c6f8a858cf2b69
# Parent e4dadbf7a05a49cd99fc6901e0f6e98ed8b32c08
[qt] make pylint a little more happy

Related to #137588

- remove unused imports
- rename unused variables
- use imports instead of globals
- use ``itertools.imap`` instead of map
- some PEP8
- do not overwrite builtins LookupError

diff --git a/hgviewlib/qt4/hgfileview.py b/hgviewlib/qt4/hgfileview.py
@@ -13,32 +13,26 @@
1  # You should have received a copy of the GNU General Public License along with
2  # this program.  If not, see <http://www.gnu.org/licenses/>.
3  """
4  Qt4 high level widgets for hg repo changelogs and filelogs
5  """
6 -import sys
7  import difflib
8 +from itertools import imap
9 
10 -from mercurial.node import hex, short as short_hex, bin as short_bin
11 -from mercurial import util
12  try:
13 -    from mercurial.error import LookupError
14 +    from mercurial.error import LookupError as HgLookupError
15  except ImportError:
16 -    from mercurial.revlog import LookupError
17 +    from mercurial.revlog import LookupError as HgLookupError
18 
19  from PyQt4 import QtCore, QtGui, Qsci
20 -from PyQt4.QtCore import pyqtSignal
21 -Qt = QtCore.Qt
22 +from PyQt4.QtCore import Qt, pyqtSignal
23 
24 -from hgviewlib.decorators import timeit
25  from hgviewlib.util import exec_flag_changed, isbfile, bfilepath, tounicode
26  from hgviewlib.config import HgConfig
27 
28  from hgviewlib.qt4 import icon as geticon
29  from hgviewlib.qt4.hgfiledialog import FileViewer, FileDiffViewer
30 -from hgviewlib.qt4.hgmanifestdialog import ManifestViewer
31 -from hgviewlib.qt4.quickbar import QuickBar
32  from hgviewlib.qt4.lexers import get_lexer
33  from hgviewlib.qt4.blockmatcher import BlockList
34 
35  qsci = Qsci.QsciScintilla
36 
@@ -76,20 +70,18 @@
37 
38          textarea.verticalScrollBar().valueChanged[int].connect(
39                  self.verticalScrollBar().setValue)
40 
41      def setFilectx(self, fctx):
42 -        self.fctx = fctx
43 -        ann = [f.rev() for f, line in fctx.annotate(follow=True)]
44 -        self.setText('\n'.join(map(str, ann)))
45 +        ann = [f.rev() for f, __ in fctx.annotate(follow=True)]
46 +        self.setText('\n'.join(imap(str, ann)))
47          allrevs = list(sorted(set(ann)))
48          for i, rev in enumerate(ann):
49              idx = allrevs.index(rev)
50              self.markerAdd(i, self.markers[idx % len(self.markers)])
51 
52 
53 -
54  class HgQsci(qsci):
55 
56      def __init__(self, *args, **kwargs):
57          super(HgQsci, self).__init__(*args, **kwargs)
58          super(HgQsci, self).setUtf8(True)
@@ -205,15 +197,15 @@
59          self._diff = None
60          self._diffs = None
61          self.cfg = None
62          QtGui.QFrame.__init__(self, parent)
63          framelayout = QtGui.QVBoxLayout(self)
64 -        framelayout.setContentsMargins(0,0,0,0)
65 +        framelayout.setContentsMargins(0, 0, 0, 0)
66          framelayout.setSpacing(0)
67 
68          l = QtGui.QHBoxLayout()
69 -        l.setContentsMargins(0,0,0,0)
70 +        l.setContentsMargins(0, 0, 0, 0)
71          l.setSpacing(0)
72 
73          self.topLayout = QtGui.QVBoxLayout()
74          self.filenamelabel = QtGui.QLabel()
75          self.filenamelabel.setWordWrap(True)
@@ -357,11 +349,11 @@
76          if filename is None:
77              return
78          try:
79              filectx = self._ctx.filectx(self._realfilename)
80 
81 -        except LookupError: # occur on deleted files
82 +        except HgLookupError: # occur on deleted files
83              return
84          if self._mode == 'diff' and self._p_rev is not None:
85              mode = self._p_rev
86          else:
87              mode = self._mode