Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf858c44

Browse files
committed
style(cmd): pythonize cmd-args filtering for PY26, improve docstring
Apply codereview comments of#541.
1 parent66306f1 commitf858c44

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

‎git/cmd.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -822,27 +822,30 @@ def _call_process(self, method, *args, **kwargs):
822822
is realized as non-existent
823823
824824
: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+
830833
git.rev_list('master', max_count=10, header=True)
834+
835+
turns into::
836+
837+
git rev-list max-count 10 --header master
831838
832839
:return: Same as ``execute``"""
833840
# Handle optional arguments prior to calling transform_kwargs
834841
# otherwise these'll end up in args, which is bad.
835-
_kwargs=dict()
836-
forkwarginexecute_kwargs:
837-
try:
838-
_kwargs[kwarg]=kwargs.pop(kwarg)
839-
exceptKeyError:
840-
pass
842+
exec_kwargs=dict((k,v)fork,vinkwargs.items()ifkinexecute_kwargs)
843+
opts_kwargs=dict((k,v)fork,vinkwargs.items()ifknotinexecute_kwargs)
841844

842-
insert_after_this_arg=kwargs.pop('insert_kwargs_after',None)
845+
insert_after_this_arg=opts_kwargs.pop('insert_kwargs_after',None)
843846

844847
# Prepare the argument list
845-
opt_args=self.transform_kwargs(**kwargs)
848+
opt_args=self.transform_kwargs(**opts_kwargs)
846849
ext_args=self.__unpack_args([aforainargsifaisnotNone])
847850

848851
ifinsert_after_this_argisNone:
@@ -851,11 +854,11 @@ def _call_process(self, method, *args, **kwargs):
851854
try:
852855
index=ext_args.index(insert_after_this_arg)
853856
exceptValueError:
854-
raiseValueError("Couldn't find argument '%s' in args %s to insertkwargs after"
857+
raiseValueError("Couldn't find argument '%s' in args %s to insertcmd options after"
855858
% (insert_after_this_arg,str(ext_args)))
856859
# end handle error
857860
args=ext_args[:index+1]+opt_args+ext_args[index+1:]
858-
# end handlekwargs
861+
# end handleopts_kwargs
859862

860863
call= [self.GIT_PYTHON_GIT_EXECUTABLE]
861864

@@ -870,7 +873,7 @@ def _call_process(self, method, *args, **kwargs):
870873
call.append(dashify(method))
871874
call.extend(args)
872875

873-
returnself.execute(call,**_kwargs)
876+
returnself.execute(call,**exec_kwargs)
874877

875878
def_parse_object_header(self,header_line):
876879
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp