summary refs log tree commit diff stats
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
parent1b97f7150f50b610c9cba20da4e4d89e27e61374 (diff)
downloadranger-2753e22e6ba3a17482709747be2de2eb6a6a719c.tar.gz
VCS: Minor fixes
-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:
' href='#n519'>519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647