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

Commit78b99d3

Browse files
committed
fix setup.py classifiers, improvefnmatchprocess handler types
1 parent70b9596 commit78b99d3

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ nbproject
2222
.pytest_cache/
2323
monkeytype.sqlite3
2424
output.txt
25+
tox.ini

‎git/cmd.py‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
6+
from __future__importannotations
77
fromcontextlibimportcontextmanager
88
importio
99
importlogging
@@ -68,7 +68,7 @@
6868
# Documentation
6969
## @{
7070

71-
defhandle_process_output(process:Union[subprocess.Popen,'Git.AutoInterrupt'],
71+
defhandle_process_output(process:'Git.AutoInterrupt'|Popen,
7272
stdout_handler:Union[None,
7373
Callable[[AnyStr],None],
7474
Callable[[List[AnyStr]],None],
@@ -78,7 +78,8 @@ def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
7878
Callable[[List[AnyStr]],None]],
7979
finalizer:Union[None,
8080
Callable[[Union[subprocess.Popen,'Git.AutoInterrupt']],None]]=None,
81-
decode_streams:bool=True)->None:
81+
decode_streams:bool=True,
82+
timeout:float=10.0)->None:
8283
"""Registers for notifications to learn that process output is ready to read, and dispatches lines to
8384
the respective line handlers.
8485
This function returns once the finalizer returns
@@ -93,9 +94,10 @@ def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
9394
their contents to handlers.
9495
Set it to False if `universal_newline == True` (then streams are in text-mode)
9596
or if decoding must happen later (i.e. for Diffs).
97+
:param timeout: float, timeout to pass to t.join() in case it hangs. Default = 10.0 seconds
9698
"""
9799
# Use 2 "pump" threads and wait for both to finish.
98-
defpump_stream(cmdline:str,name:str,stream:Union[BinaryIO,TextIO],is_decode:bool,
100+
defpump_stream(cmdline:List[str],name:str,stream:Union[BinaryIO,TextIO],is_decode:bool,
99101
handler:Union[None,Callable[[Union[bytes,str]],None]])->None:
100102
try:
101103
forlineinstream:
@@ -107,22 +109,34 @@ def pump_stream(cmdline: str, name: str, stream: Union[BinaryIO, TextIO], is_dec
107109
else:
108110
handler(line)
109111
exceptExceptionasex:
110-
log.error("Pumping%r of cmd(%s) failed due to:%r",name,remove_password_if_present(cmdline),ex)
111-
raiseCommandError(['<%s-pump>'%name]+remove_password_if_present(cmdline),ex)fromex
112+
log.error(f"Pumping{name!r} of cmd({remove_password_if_present(cmdline)})}faileddueto:{ex!r}")
113+
raiseCommandError([f'<{name}-pump>']+remove_password_if_present(cmdline),ex)fromex
112114
finally:
113115
stream.close()
114116

115-
cmdline=getattr(process,'args','')# PY3+ only
117+
118+
119+
ifhasattr(process,'proc'):
120+
process=cast('Git.AutoInterrupt',process)
121+
cmdline:str|Tuple[str, ...]|List[str]=getattr(process.proc,'args','')
122+
p_stdout=process.proc.stdout
123+
p_stderr=process.proc.stderr
124+
else:
125+
process=cast(Popen,process)
126+
cmdline=getattr(process,'args','')
127+
p_stdout=process.stdout
128+
p_stderr=process.stderr
129+
116130
ifnotisinstance(cmdline, (tuple,list)):
117131
cmdline=cmdline.split()
118132

119-
pumps= []
120-
ifprocess.stdout:
121-
pumps.append(('stdout',process.stdout,stdout_handler))
122-
ifprocess.stderr:
123-
pumps.append(('stderr',process.stderr,stderr_handler))
133+
pumps:List[Tuple[str,IO,Callable[...,None]|None]]= []
134+
ifp_stdout:
135+
pumps.append(('stdout',p_stdout,stdout_handler))
136+
ifp_stderr:
137+
pumps.append(('stderr',p_stderr,stderr_handler))
124138

125-
threads= []
139+
threads:List[threading.Thread]= []
126140

127141
forname,stream,handlerinpumps:
128142
t=threading.Thread(target=pump_stream,
@@ -134,7 +148,7 @@ def pump_stream(cmdline: str, name: str, stream: Union[BinaryIO, TextIO], is_dec
134148
## FIXME: Why Join?? Will block if `stdin` needs feeding...
135149
#
136150
fortinthreads:
137-
t.join()
151+
t.join(timeout=timeout)
138152

139153
iffinalizer:
140154
returnfinalizer(process)

‎requirements-dev.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ flake8-type-checking;python_version>="3.8" # checks for TYPE_CHECKING only
1212
# pytest-flake8
1313
pytest-icdiff
1414
# pytest-profiling
15+
16+
17+
tox

‎setup.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ def build_py_modules(basedir: str, excludes: Sequence = ()) -> Sequence:
113113
"Operating System :: POSIX",
114114
"Operating System :: Microsoft :: Windows",
115115
"Operating System :: MacOS :: MacOS X",
116-
"Typing:: Typed",
116+
"Typing:: Typed",
117117
"Programming Language :: Python",
118118
"Programming Language :: Python :: 3",
119119
"Programming Language :: Python :: 3.7",
120120
"Programming Language :: Python :: 3.8",
121-
"Programming Language :: Python :: 3.9"
121+
"Programming Language :: Python :: 3.9",
122122
"Programming Language :: Python :: 3.10"
123123
]
124124
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp