summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2016-02-07 23:33:10 +0100
committernfnty <git@nfnty.se>2016-02-08 04:43:04 +0100
commit2753e22e6ba3a17482709747be2de2eb6a6a719c (patch)
tree93837180493b9b1e4d1e7d1bc9d060c05d49befd /ranger
parent1b97f7150f50b610c9cba20da4e4d89e27e61374 (diff)
downloadranger-2753e22e6ba3a17482709747be2de2eb6a6a719c.tar.gz
VCS: Minor fixes
Diffstat (limited to 'ranger')
-rw-r--r--ranger/ext/vcs/__init__.py4
-rw-r--r--ranger/ext/vcs/bzr.py14
-rw-r--r--ranger/ext/vcs/git.py22
-rw-r--r--ranger/ext/vcs/hg.py1
-rw-r--r--ranger/ext/vcs/svn.py1
-rw-r--r--ranger/ext/vcs/vcs.py6
6 files changed, 25 insertions, 23 deletions
diff --git a/ranger/ext/vcs/__init__.py b/ranger/ext/vcs/__init__.py
index ec26f07a..26a32800 100644
--- a/ranger/ext/vcs/__init__.py
+++ b/ranger/ext/vcs/__init__.py
@@ -3,4 +3,6 @@
 
 """VCS Extension"""
 
-from .vcs import Vcs, VcsError, VcsThread  # NOQA
+from .vcs import Vcs, VcsError, VcsThread
+
+__all__ = ['Vcs', 'VcsError', 'VcsThread']
diff --git a/ranger/ext/vcs/bzr.py b/ranger/ext/vcs/bzr.py
index 300db796..11461f97 100644
--- a/ranger/ext/vcs/bzr.py
+++ b/ranger/ext/vcs/bzr.py
@@ -6,6 +6,7 @@
 import os
 import re
 from datetime import datetime
+
 from .vcs import Vcs, VcsError
 
 
@@ -26,9 +27,9 @@ class Bzr(Vcs):
         return self._vcs(['bzr'] + args, path or self.path, catchout=catchout, retbytes=retbytes)
 
     def _remote_url(self):
-        """Returns remote url"""
+        """Remote url"""
         try:
-            return self._bzr(['config', 'parent_location']).rstrip() or None
+            return self._bzr(['config', 'parent_location']).rstrip('\n') or None
         except VcsError:
             return None
 
@@ -65,8 +66,8 @@ class Bzr(Vcs):
 
     def _bzr_status_translate(self, code):
         """Translate status code"""
-        for X, Y, status in self._status_translations:
-            if code[0] in X and code[1] in Y:
+        for code_x, code_y, status in self._status_translations:
+            if code[0] in code_x and code[1] in code_y:
                 return status
         return 'unknown'
 
@@ -114,12 +115,11 @@ class Bzr(Vcs):
     def data_status_remote(self):
         if not self._remote_url():
             return 'none'
-
         return 'unknown'
 
     def data_branch(self):
         try:
-            return self._bzr(['nick']).rstrip() or None
+            return self._bzr(['nick']).rstrip('\n') or None
         except VcsError:
             return None
 
@@ -136,4 +136,4 @@ class Bzr(Vcs):
         elif len(log) == 1:
             return log[0]
         else:
-            raise VcsError('More than one instance of revision {0:s} ?!?'.format(rev))
+            raise VcsError('More than one instance of revision {0:s}'.format(rev))
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py
index 5007b877..e64055a1 100644
--- a/ranger/ext/vcs/git.py
+++ b/ranger/ext/vcs/git.py
@@ -7,6 +7,7 @@ import os
 import re
 from datetime import datetime
 import json
+
 from .vcs import Vcs, VcsError
 
 
@@ -33,13 +34,13 @@ class Git(Vcs):
 
     def _head_ref(self):
         """Returns HEAD reference"""
-        return self._git(['symbolic-ref', self.HEAD]).rstrip() or None
+        return self._git(['symbolic-ref', self.HEAD]).rstrip('\n') or None
 
     def _remote_ref(self, ref):
         """Returns remote reference associated to given ref"""
         if ref is None:
             return None
-        return self._git(['for-each-ref', '--format=%(upstream)', ref]).rstrip() or None
+        return self._git(['for-each-ref', '--format=%(upstream)', ref]).rstrip('\n') or None
 
     def _log(self, refspec=None, maxres=None, filelist=None):
         """Returns an array of dicts containing revision info for refspec"""
@@ -73,10 +74,10 @@ class Git(Vcs):
             log.append(line)
         return log
 
-    def _git_status_translate(self, code):
+    def _status_translate(self, code):
         """Translate status code"""
-        for X, Y, status in self._status_translations:  # pylint: disable=invalid-name
-            if code[0] in X and code[1] in Y:
+        for code_x, code_y, status in self._status_translations:
+            if code[0] in code_x and code[1] in code_y:
                 return status
         return 'unknown'
 
@@ -105,7 +106,7 @@ class Git(Vcs):
             if skip:
                 skip = False
                 continue
-            statuses.add(self._git_status_translate(line[:2]))
+            statuses.add(self._status_translate(line[:2]))
             if line.startswith('R'):
                 skip = True
 
@@ -136,7 +137,7 @@ class Git(Vcs):
             if skip:
                 skip = False
                 continue
-            statuses[os.path.normpath(line[3:])] = self._git_status_translate(line[:2])
+            statuses[os.path.normpath(line[3:])] = self._status_translate(line[:2])
             if line.startswith('R'):
                 skip = True
 
@@ -168,10 +169,7 @@ class Git(Vcs):
             return 'detached'
 
         match = re.match('refs/heads/([^/]+)', head)
-        if match:
-            return match.group(1)
-        else:
-            return None
+        return match.group(1) if match else None
 
     def data_info(self, rev=None):
         if rev is None:
@@ -186,4 +184,4 @@ class Git(Vcs):
         elif len(log) == 1:
             return log[0]
         else:
-            raise VcsError('More than one instance of revision {0:s} ?!?'.format(rev))
+            raise VcsError('More than one instance of revision {0:s}'.format(rev))
diff --git a/ranger/ext/vcs/hg.py b/ranger/ext/vcs/hg.py
index 39a81d57..02d8e684 100644
--- a/ranger/ext/vcs/hg.py
+++ b/ranger/ext/vcs/hg.py
@@ -6,6 +6,7 @@
 import os
 import re
 from datetime import datetime
+
 from .vcs import Vcs, VcsError
 
 class Hg(Vcs):
diff --git a/ranger/ext/vcs/svn.py b/ranger/ext/vcs/svn.py
index a8ee66f3..c152ca7c 100644
--- a/ranger/ext/vcs/svn.py
+++ b/ranger/ext/vcs/svn.py
@@ -8,6 +8,7 @@ import os
 import re
 import logging
 from datetime import datetime
+
 from .vcs import Vcs, VcsError
 
 class SVN(Vcs):
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index f4e0f378..93db5eab 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -169,7 +169,7 @@ class Vcs(object):  # pylint: disable=too-many-instance-attributes
         self.rootinit = True
         return True
 
-    def _update_walk(self, path, purge):
+    def _update_walk(self, path, purge):  # pylint: disable=too-many-branches
         """Update walk"""
         for wroot, wdirs, _ in os.walk(path):
             # Only update loaded directories
@@ -355,7 +355,7 @@ class Vcs(object):  # pylint: disable=too-many-instance-attributes
         raise NotImplementedError
 
 
-class VcsThread(threading.Thread):
+class VcsThread(threading.Thread):  # pylint: disable=too-many-instance-attributes
     """VCS thread"""
     def __init__(self, ui, idle_delay):
         super(VcsThread, self).__init__()
@@ -388,7 +388,7 @@ class VcsThread(threading.Thread):
                     return target
         return None
 
-    def _queue_process(self):
+    def _queue_process(self):  # pylint: disable=too-many-branches
         """Process queue: Initialize roots under dirobj"""
 
         while True: