Skip to content

Commit

Permalink
fix protocol kwarg-forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed Oct 26, 2023
1 parent d9ce552 commit 7fa4257
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions datalad_next/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from .protocols import (
NoCaptureGeneratorProtocol,
StdOutCaptureGeneratorProtocol,
StdOutLineCaptureGeneratorProtocol,
)
# exceptions
from datalad.runner.exception import (
Expand Down
8 changes: 6 additions & 2 deletions datalad_next/runners/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def batchcommand(
cwd: Path | None = None,
terminate_time: int | None = None,
kill_time: int | None = None,
**protocol_kwargs
protocol_kwargs: dict | None = None,
) -> Generator[BatchProcess, None, None]:
"""Generic context manager for batch processes
Expand Down Expand Up @@ -154,7 +154,7 @@ def batchcommand(
cwd=cwd,
terminate_time=terminate_time,
kill_time=kill_time,
**protocol_kwargs
protocol_kwargs=protocol_kwargs
) as result_generator:
batch_process = BatchProcess(result_generator)
yield batch_process
Expand Down Expand Up @@ -189,6 +189,7 @@ def annexjson_batchcommand(
cwd: Path | None = None,
terminate_time: int | None = None,
kill_time: int | None = None,
protocol_kwargs: dict | None = None,
) -> Generator[BatchProcess, None, None]:
"""
Context manager for git-annex commands that support ``--batch --json``
Expand All @@ -207,6 +208,7 @@ def annexjson_batchcommand(
cwd=cwd,
terminate_time=terminate_time,
kill_time=kill_time,
protocol_kwargs=protocol_kwargs,
)


Expand All @@ -215,6 +217,7 @@ def annexline_batchcommand(
cwd: Path | None = None,
terminate_time: int | None = None,
kill_time: int | None = None,
protocol_kwargs: dict | None = None,
) -> Generator[BatchProcess, None, None]:
"""
Context manager for git-annex commands that support ``--batch --json``
Expand All @@ -233,4 +236,5 @@ def annexline_batchcommand(
cwd=cwd,
terminate_time=terminate_time,
kill_time=kill_time,
protocol_kwargs=protocol_kwargs,
)
9 changes: 7 additions & 2 deletions datalad_next/runners/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ def timeout(self, fd):


class StdOutLineCaptureGeneratorProtocol(StdOutCapture, GeneratorMixIn):
def __init__(self, done_future=None, encoding=None):
def __init__(self,
done_future=None,
encoding=None,
separator: Optional[str] = None,
keep_ends: bool = False
):
from . import LineSplitter

StdOutCapture.__init__(self, done_future, encoding)
GeneratorMixIn.__init__(self)
self.encoding = encoding or 'utf-8'
self.line_splitter = LineSplitter()
self.line_splitter = LineSplitter(separator, keep_ends)

def pipe_data_received(self, fd: int, data: bytes):
assert fd == 1
Expand Down

0 comments on commit 7fa4257

Please sign in to comment.