| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 66306f1 commit f858c44
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -822,27 +822,30 @@ def _call_process(self, method, *args, **kwargs): | |||
| 822 | 822 | is realized as non-existent | |
| 823 | 823 | ||
| 824 | 824 | :param kwargs: | |
| 825 | - is a dict of keyword arguments. | ||
| 826 | - This function accepts the same optional keyword arguments | ||
| 827 | - as execute(). | ||
| 828 | - | ||
| 829 | - ``Examples``:: | ||
| 825 | + It contains key-values for the following: | ||
| 826 | + - the :meth:`execute()` kwds, as listed in :var:`execute_kwargs`; | ||
| 827 | + - "command options" to be converted by :meth:`transform_kwargs()`; | ||
| 828 | + - the `'insert_kwargs_after'` key which its value must match one of ``*args``, | ||
| 829 | + and any cmd-options will be appended after the matched arg. | ||
| 830 | + | ||
| 831 | + Examples:: | ||
| 832 | + | ||
| 830 | 833 | git.rev_list('master', max_count=10, header=True) | |
| 834 | + | ||
| 835 | + turns into:: | ||
| 836 | + | ||
| 837 | + git rev-list max-count 10 --header master | ||
| 831 | 838 | ||
| 832 | 839 | :return: Same as ``execute``""" | |
| 833 | 840 | # Handle optional arguments prior to calling transform_kwargs | |
| 834 | 841 | # otherwise these'll end up in args, which is bad. | |
| 835 | - _kwargs = dict() | ||
| 836 | - for kwarg in execute_kwargs: | ||
| 837 | - try: | ||
| 838 | - _kwargs[kwarg] = kwargs.pop(kwarg) | ||
| 839 | - except KeyError: | ||
| 840 | - pass | ||
| 842 | + exec_kwargs = dict((k, v) for k, v in kwargs.items() if k in execute_kwargs) | ||
| 843 | + opts_kwargs = dict((k, v) for k, v in kwargs.items() if k not in execute_kwargs) | ||
| 841 | 844 | ||
| 842 | - insert_after_this_arg = kwargs.pop('insert_kwargs_after', None) | ||
| 845 | + insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None) | ||
| 843 | 846 | ||
| 844 | 847 | # Prepare the argument list | |
| 845 | - opt_args = self.transform_kwargs(**kwargs) | ||
| 848 | + opt_args = self.transform_kwargs(**opts_kwargs) | ||
| 846 | 849 | ext_args = self.__unpack_args([a for a in args if a is not None]) | |
| 847 | 850 | ||
| 848 | 851 | if insert_after_this_arg is None: | |
@@ -851,11 +854,11 @@ def _call_process(self, method, *args, **kwargs): | |||
| 851 | 854 | try: | |
| 852 | 855 | index = ext_args.index(insert_after_this_arg) | |
| 853 | 856 | except ValueError: | |
| 854 | - raise ValueError("Couldn't find argument '%s' in args %s to insert kwargs after" | ||
| 857 | + raise ValueError("Couldn't find argument '%s' in args %s to insert cmd options after" | ||
| 855 | 858 | % (insert_after_this_arg, str(ext_args))) | |
| 856 | 859 | # end handle error | |
| 857 | 860 | args = ext_args[:index + 1] + opt_args + ext_args[index + 1:] | |
| 858 | - # end handle kwargs | ||
| 861 | + # end handle opts_kwargs | ||
| 859 | 862 | ||
| 860 | 863 | call = [self.GIT_PYTHON_GIT_EXECUTABLE] | |
| 861 | 864 | ||
@@ -870,7 +873,7 @@ def _call_process(self, method, *args, **kwargs): | |||
| 870 | 873 | call.append(dashify(method)) | |
| 871 | 874 | call.extend(args) | |
| 872 | 875 | ||
| 873 | - return self.execute(call, **_kwargs) | ||
| 876 | + return self.execute(call, **exec_kwargs) | ||
| 874 | 877 | ||
| 875 | 878 | def _parse_object_header(self, header_line): | |
| 876 | 879 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments