-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
99 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,15 +32,15 @@ | |
# from __future__ import absolute_import | ||
import subprocess | ||
import re | ||
import logging | ||
try: # pragma: no cover | ||
from tabulate import tabulate as tabber | ||
raise ImportError("alpha feature: tabulate") | ||
except ImportError: # pragma: no cover | ||
tabber = None | ||
|
||
from ._utils import TERM_WIDTH, int_cast_or_len, Max, fext, _str, tqdm, \ | ||
check_output | ||
import logging | ||
from ._utils import TERM_WIDTH, int_cast_or_len, Max, fext, _str, \ | ||
check_output, tqdm, TqdmStream | ||
from ._version import __version__ # NOQA | ||
|
||
__author__ = "Casper da Costa-Luis <[email protected]>" | ||
|
@@ -204,7 +204,8 @@ def run(args): | |
log.log(logging.NOTSET, "files:\n" + '\n'.join(file_list)) | ||
|
||
auth_stats = {} | ||
for fname in tqdm(file_list, desc="Blame", disable=args.silent_progress): | ||
for fname in tqdm(file_list, desc="Blame", disable=args.silent_progress, | ||
unit="file"): | ||
git_blame_cmd = git_cmd + ["blame", "--line-porcelain", branch, fname] | ||
if args.ignore_whitespace: | ||
git_blame_cmd.append("-w") | ||
|
@@ -281,7 +282,9 @@ def main(): | |
from argopt import argopt | ||
args = argopt(__doc__ + '\n' + __copyright__, | ||
version=__version__).parse_args() | ||
logging.basicConfig(level=getattr(logging, args.log, logging.INFO)) | ||
logging.basicConfig( | ||
level=getattr(logging, args.log, logging.INFO), | ||
stream=TqdmStream) | ||
log = logging.getLogger(__name__) | ||
|
||
log.debug(args) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,36 @@ | |
import subprocess | ||
import logging | ||
|
||
if True: # pragma: no cover | ||
try: | ||
from tqdm import tqdm | ||
except ImportError: | ||
print ('info | install `tqdm` (https://github.com/tqdm/tqdm) for\n' + | ||
' | a realitme progressbar') | ||
|
||
def tqdm(*args, **kwargs): | ||
if args: | ||
return args[0] | ||
return kwargs.get('iterable', None) | ||
|
||
try: | ||
_str = unicode # python2 | ||
except NameError: | ||
_str = str # python3 | ||
|
||
try: | ||
_range = xrange # python2 | ||
except NameError: | ||
_range = range # python3 | ||
try: | ||
# python2 | ||
_str = unicode | ||
_range = xrange | ||
except NameError: | ||
# python3 | ||
_str = str | ||
_range = range | ||
|
||
try: | ||
from tqdm import tqdm | ||
except ImportError: | ||
class tqdm(object): | ||
def __init__(self, iterable=None, **kwargs): | ||
log = logging.getLogger(__name__) | ||
log.info('install `tqdm` (https://github.com/tqdm/tqdm)' | ||
' for a realitme progressbar') | ||
self.iterable = iterable | ||
self.n = 0 | ||
|
||
def __iter__(self): | ||
for i in self.iterable: | ||
self.n += 1 | ||
sys.stderr.write("%d/%d\r" % (self.n, len(self.iterable))) | ||
sys.stderr.flush() | ||
yield i | ||
|
||
@classmethod | ||
def write(cls, msg, end='\n'): | ||
sys.stderr.write(msg + end) | ||
|
||
__author__ = "Casper da Costa-Luis <[email protected]>" | ||
__date__ = "2016" | ||
|
@@ -33,6 +42,17 @@ def tqdm(*args, **kwargs): | |
__license__ = __licence__ # weird foreign language | ||
|
||
|
||
class TqdmStream(object): | ||
@classmethod | ||
def write(cls, msg): | ||
tqdm.write(msg, end='') | ||
|
||
# is this required? | ||
# @classmethod | ||
# def flush(_): | ||
# pass | ||
|
||
|
||
def check_output(*a, **k): | ||
log = logging.getLogger(__name__) | ||
log.debug(' '.join(a[0][3:])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters