diff options
author | Barry Scott <barry@barrys-emacs.org> | 2016-05-28 12:05:23 +0100 |
---|---|---|
committer | Barry Scott <barry@barrys-emacs.org> | 2016-05-28 12:05:23 +0100 |
commit | b4492c7965cd8e3c5faaf28b2a6414b04984720b (patch) | |
tree | 201c035534ac5809a3ef2436bdf7826775d195b5 /git/util.py | |
parent | bed46300fe5dcb376d43da56bbcd448d73bb2ea0 (diff) | |
download | gitpython-b4492c7965cd8e3c5faaf28b2a6414b04984720b.tar.gz |
The progress arg to push, pull, fetch and clone is now a python callable.
This simplifies the API and removes the parser, RemoteProgres,
from the API as RemoteProgress is an internal detail of the implementation.
progress is accepted as:
* None - drop progress messages
* callable (function etc) - call the function with the same args as update
* object - assume its RemoteProgress derived as use as before
RemoteProgress takes an optional progress_function argument.
It will call the progress function if not None otherwise call self.update
as it used to.
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/git/util.py b/git/util.py index a267f183..9b86b191 100644 --- a/git/util.py +++ b/git/util.py @@ -174,11 +174,16 @@ class RemoteProgress(object): DONE_TOKEN = 'done.' TOKEN_SEPARATOR = ', ' - __slots__ = ("_cur_line", "_seen_ops") + __slots__ = ("_cur_line", "_seen_ops", "__progress_function") re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)") re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)") - def __init__(self): + def __init__(self, progress_function=None): + if progress_function is not None: + self.__progress_function = progress_function + else: + self.__progress_function = self.update + self._seen_ops = list() self._cur_line = None @@ -267,7 +272,7 @@ class RemoteProgress(object): # END end message handling message = message.strip(self.TOKEN_SEPARATOR) - self.update(op_code, + self.__progress_function(op_code, cur_count and float(cur_count), max_count and float(max_count), message) @@ -314,7 +319,6 @@ class RemoteProgress(object): You may read the contents of the current line in self._cur_line""" pass - class Actor(object): """Actors hold information about a person acting on the repository. They |