| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ece57af commit 98889c3
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,8 @@ def add_progress(kwargs, git, progress): | |||
| 58 | 58 | ||
| 59 | 59 | #} END utilities | |
| 60 | 60 | ||
| 61 | - def progress_object(progress): | ||
| 61 | + | ||
| 62 | + def to_progress_instance(progress): | ||
| 62 | 63 | """Given the 'progress' return a suitable object derived from | |
| 63 | 64 | RemoteProgress(). | |
| 64 | 65 | """ | |
@@ -552,9 +553,8 @@ def update(self, **kwargs): | |||
| 552 | 553 | self.repo.git.remote(scmd, self.name, **kwargs) | |
| 553 | 554 | return self | |
| 554 | 555 | ||
| 555 | - | ||
| 556 | 556 | def _get_fetch_info_from_stderr(self, proc, progress): | |
| 557 | - progress = progress_object(progress) | ||
| 557 | + progress = to_progress_instance(progress) | ||
| 558 | 558 | ||
| 559 | 559 | # skip first line as it is some remote info we are not interested in | |
| 560 | 560 | output = IterableList('name') | |
@@ -610,7 +610,7 @@ def _get_fetch_info_from_stderr(self, proc, progress): | |||
| 610 | 610 | return output | |
| 611 | 611 | ||
| 612 | 612 | def _get_push_info(self, proc, progress): | |
| 613 | - progress = progress_object(progress) | ||
| 613 | + progress = to_progress_instance(progress) | ||
| 614 | 614 | ||
| 615 | 615 | # read progress information from stderr | |
| 616 | 616 | # we hope stdout can hold all the data, it should ... | |
@@ -715,26 +715,19 @@ def push(self, refspec=None, progress=None, **kwargs): | |||
| 715 | 715 | ||
| 716 | 716 | :param refspec: see 'fetch' method | |
| 717 | 717 | :param progress: | |
| 718 | - If None, progress information will be discarded | ||
| 719 | - | ||
| 720 | - No further progress information is returned after push returns. | ||
| 721 | - | ||
| 722 | - A function (callable) that is called with the progress infomation: | ||
| 723 | - | ||
| 724 | - progress( op_code, cur_count, max_count=None, message='' ) | ||
| 725 | - | ||
| 726 | - op_code is a bit mask of values defined in git.RemoteProgress | ||
| 727 | - | ||
| 728 | - cur_count and max_count are float values. | ||
| 729 | - | ||
| 730 | - max_count is None if there is no max_count | ||
| 731 | - | ||
| 732 | - messages is '' if there is no additon message. | ||
| 733 | - | ||
| 734 | - Deprecated: Pass in a class derived from git.RemoteProgres that | ||
| 735 | - overrides the update() function. | ||
| 736 | - | ||
| 737 | - | ||
| 718 | + Can take one of many value types: | ||
| 719 | + | ||
| 720 | + * None to discard progress information | ||
| 721 | + * A function (callable) that is called with the progress infomation. | ||
| 722 | + | ||
| 723 | + Signature: ``progress(op_code, cur_count, max_count=None, message='')``. | ||
| 724 | + | ||
| 725 | + `Click here <http://goo.gl/NPa7st>`_ for a description of all arguments | ||
| 726 | + given to the function. | ||
| 727 | + * An instance of a class derived from ``git.RemoteProgress`` that | ||
| 728 | + overrides the ``update()`` function. | ||
| 729 | + | ||
| 730 | + :note: No further progress information is returned after push returns. | ||
| 738 | 731 | :param kwargs: Additional arguments to be passed to git-push | |
| 739 | 732 | :return: | |
| 740 | 733 | IterableList(PushInfo, ...) iterable list of PushInfo instances, each | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ | |||
| 33 | 33 | from git.remote import ( | |
| 34 | 34 | Remote, | |
| 35 | 35 | add_progress, | |
| 36 | - progress_object | ||
| 36 | + to_progress_instance | ||
| 37 | 37 | ) | |
| 38 | 38 | ||
| 39 | 39 | from git.db import GitCmdObjectDB | |
@@ -873,7 +873,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs): | |||
| 873 | 873 | ||
| 874 | 874 | @classmethod | |
| 875 | 875 | def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | |
| 876 | - progress = progress_object(progress) | ||
| 876 | + progress = to_progress_instance(progress) | ||
| 877 | 877 | ||
| 878 | 878 | # special handling for windows for path at which the clone should be | |
| 879 | 879 | # created. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,11 +179,7 @@ class RemoteProgress(object): | |||
| 179 | 179 | re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)") | |
| 180 | 180 | ||
| 181 | 181 | def __init__(self, progress_function=None): | |
| 182 | - if progress_function is not None: | ||
| 183 | - self.__progress_function = progress_function | ||
| 184 | - else: | ||
| 185 | - self.__progress_function = self.update | ||
| 186 | - | ||
| 182 | + self.__progress_function = progress_function if progress_function else self.update | ||
| 187 | 183 | self._seen_ops = list() | |
| 188 | 184 | self._cur_line = None | |
| 189 | 185 | ||
@@ -273,9 +269,9 @@ def _parse_progress_line(self, line): | |||
| 273 | 269 | message = message.strip(self.TOKEN_SEPARATOR) | |
| 274 | 270 | ||
| 275 | 271 | self.__progress_function(op_code, | |
| 276 | - cur_count and float(cur_count), | ||
| 277 | - max_count and float(max_count), | ||
| 278 | - message) | ||
| 272 | + cur_count and float(cur_count), | ||
| 273 | + max_count and float(max_count), | ||
| 274 | + message) | ||
| 279 | 275 | # END for each sub line | |
| 280 | 276 | return failed_lines | |
| 281 | 277 | ||
@@ -319,6 +315,7 @@ def update(self, op_code, cur_count, max_count=None, message=''): | |||
| 319 | 315 | You may read the contents of the current line in self._cur_line""" | |
| 320 | 316 | pass | |
| 321 | 317 | ||
| 318 | + | ||
| 322 | 319 | class Actor(object): | |
| 323 | 320 | ||
| 324 | 321 | """Actors hold information about a person acting on the repository. They | |
| Back | FazBrowse Home | New Git URL |
0 commit comments