mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Implement a simplified xargs in python
This commit is contained in:
parent
a5b56bd9e3
commit
b7d395410b
13 changed files with 130 additions and 62 deletions
|
|
@ -160,7 +160,6 @@ class CalledProcessError(RuntimeError):
|
|||
|
||||
def cmd_output(*cmd, **kwargs):
|
||||
retcode = kwargs.pop('retcode', 0)
|
||||
stdin = kwargs.pop('stdin', None)
|
||||
encoding = kwargs.pop('encoding', 'UTF-8')
|
||||
__popen = kwargs.pop('__popen', subprocess.Popen)
|
||||
|
||||
|
|
@ -170,9 +169,6 @@ def cmd_output(*cmd, **kwargs):
|
|||
'stderr': subprocess.PIPE,
|
||||
}
|
||||
|
||||
if stdin is not None:
|
||||
stdin = stdin.encode('UTF-8')
|
||||
|
||||
# py2/py3 on windows are more strict about the types here
|
||||
cmd = [five.n(arg) for arg in cmd]
|
||||
kwargs['env'] = dict(
|
||||
|
|
@ -182,7 +178,7 @@ def cmd_output(*cmd, **kwargs):
|
|||
|
||||
popen_kwargs.update(kwargs)
|
||||
proc = __popen(cmd, **popen_kwargs)
|
||||
stdout, stderr = proc.communicate(stdin)
|
||||
stdout, stderr = proc.communicate()
|
||||
if encoding is not None and stdout is not None:
|
||||
stdout = stdout.decode(encoding)
|
||||
if encoding is not None and stderr is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue