Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbairak committed Mar 9, 2024
1 parent e2ff95b commit 1342b76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
27 changes: 14 additions & 13 deletions src/pipepy/pipepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ def set_interactive(value):
INTERACTIVE = value


# Forward calls to background process
def _map_to_background_process(method):
"""Expose the `send_signal`, `terminate` and `kill` methods of Popen
objects to PipePy objects.
"""

def func(self, *args, **kwargs):
if self._process is None:
raise TypeError(f"Cannot call '{method}' on non-background process")
getattr(self._process, method)(*args, **kwargs)

return func


class PipePy:
# Init and copies
def __init__(
Expand Down Expand Up @@ -922,19 +936,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
job = job._input
job.wait()

# Forward calls to background process
def _map_to_background_process(method):
"""Expose the `send_signal`, `terminate` and `kill` methods of Popen
objects to PipePy objects.
"""

def func(self, *args, **kwargs):
if self._process is None:
raise TypeError(f"Cannot call '{method}' on non-background process")
getattr(self._process, method)(*args, **kwargs)

return func

send_signal = _map_to_background_process("send_signal")
terminate = _map_to_background_process("terminate")
kill = _map_to_background_process("kill")
8 changes: 6 additions & 2 deletions src/pipepy/pymake.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def pymake(*args):
targets = []
for arg in args:
if "=" in arg:
key, value = arg.split("=")
key, value = arg.split("=", 1)
if hasattr(Makefile, key):
setattr(Makefile, key, value)
command_args[key] = value
Expand Down Expand Up @@ -184,7 +184,11 @@ def _pymake_complete(args):
continue
if func.__doc__:
doc = func.__doc__
doc = doc.replace("'", "\\'").replace(":", "\\:").replace("\\", "\\\\")
doc = (
doc.replace("\\", "\\\\")
.replace(":", "\\:")
.replace("'", "'\"'\"'")
)
doc = " ".join([line.strip() for line in doc.splitlines()])
result += f" '{attr}:{doc}'"
else:
Expand Down

0 comments on commit 1342b76

Please sign in to comment.