swiftly/cli/iomanager.py
def with_stdin(self, os_path=None, skip_sub_command=False,
                   disk_closed_callback=None):
        """
        A context manager yielding a stdin-suitable file-like object
        based on the optional os_path and optionally skipping any
        configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.
        """
        sub_command = None if skip_sub_command else self.stdin_sub_command
        inn, path = self._get_in_and_path(
            self.stdin, self.stdin_root, sub_command, os_path)
        try:
            if hasattr(inn, 'stdout'):
                yield inn.stdout
            else:
                yield inn
        finally:
            if hasattr(inn, 'stdout'):
                self._close(inn.stdout)
            self._wait(inn, path)
            self._close(inn)
            if disk_closed_callback and path:
                disk_closed_callback(path)
def with_stdin(self, os_path=None, skip_sub_command=False,
                   disk_closed_callback=None):
        """
        A context manager yielding a stdin-suitable file-like object
        based on the optional os_path and optionally skipping any
        configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.
        """
        sub_command = None if skip_sub_command else self.stdin_sub_command
        inn, path = self._get_in_and_path(
            self.stdin, self.stdin_root, sub_command, os_path)
        try:
            if hasattr(inn, 'stdout'):
                yield inn.stdout
            else:
                yield inn
        finally:
            if hasattr(inn, 'stdout'):
                self._close(inn.stdout)
            self._wait(inn, path)
            self._close(inn)
            if disk_closed_callback and path:
                disk_closed_callback(path)
A context manager yielding a stdin-suitable file-like object
        based on the optional os_path and optionally skipping any
        configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.