# Path: esc/consts.py
# REQUIRED_TERM_HEIGHT = 24
# 
# REQUIRED_TERM_WIDTH = 80
# 
# Path: esc/oops.py
# class ProgrammingError(EscError):
#     r"""
#     Indicates an error caused by incorrectly written or defined esc
#     plugins. This includes modes, menus, operations, and so on.
#     It does not include runtime errors within operation functions
#     themselves; these are :class:`FunctionExecutionError`\ s.
#     """


import curses
import decimal
import inspect
import itertools
import sys
from .consts import REQUIRED_TERM_HEIGHT, REQUIRED_TERM_WIDTH
from .oops import ProgrammingError
            f"requested the following arguments which are not available: "
            f"{', '.join(unavailable)}. "
            f"Available arguments are as follows: "
            f"{', '.join(available_kwargs.keys())}.")

    return func(**{k: v for k, v in available_kwargs.items() if k in requested})


def partition(pred, iterable):
    """
    Use a predicate to partition entries into false entries and true entries.
    Itertools recipe from the standard library documentation.

    >>> [list(i) for i in partition(lambda i: i % 2 == 0, [1, 2, 3, 4, 5])]
    [[1, 3, 5], [2, 4]]

    >>> [list(i) for i in partition(lambda i: True, [1, 2, 3, 4, 5])]
    [[], [1, 2, 3, 4, 5]]
    """
    t1, t2 = itertools.tee(iterable)
    return itertools.filterfalse(pred, t1), filter(pred, t2)


def quit_if_screen_too_small(max_y, max_x):
    """
    If the terminal is too small, quit, providing a useful error message.
    """
    if max_y < REQUIRED_TERM_HEIGHT or max_x < REQUIRED_TERM_WIDTH:
        curses.endwin()
        sys.stderr.write(f"esc requires at least a "

# Path: esc/consts.py
# REQUIRED_TERM_HEIGHT = 24
# 
# REQUIRED_TERM_WIDTH = 80
# 
# Path: esc/oops.py
# class ProgrammingError(EscError):
#     r"""
#     Indicates an error caused by incorrectly written or defined esc
#     plugins. This includes modes, menus, operations, and so on.
#     It does not include runtime errors within operation functions
#     themselves; these are :class:`FunctionExecutionError`\ s.
#     """


# Path: esc/util.py
import curses
import decimal
import inspect
import itertools
import sys
from .consts import REQUIRED_TERM_HEIGHT, REQUIRED_TERM_WIDTH
from .oops import ProgrammingError

            f"requested the following arguments which are not available: "
            f"{', '.join(unavailable)}. "
            f"Available arguments are as follows: "
            f"{', '.join(available_kwargs.keys())}.")

    return func(**{k: v for k, v in available_kwargs.items() if k in requested})


def partition(pred, iterable):
    """
    Use a predicate to partition entries into false entries and true entries.
    Itertools recipe from the standard library documentation.

    >>> [list(i) for i in partition(lambda i: i % 2 == 0, [1, 2, 3, 4, 5])]
    [[1, 3, 5], [2, 4]]

    >>> [list(i) for i in partition(lambda i: True, [1, 2, 3, 4, 5])]
    [[], [1, 2, 3, 4, 5]]
    """
    t1, t2 = itertools.tee(iterable)
    return itertools.filterfalse(pred, t1), filter(pred, t2)


def quit_if_screen_too_small(max_y, max_x):
    """
    If the terminal is too small, quit, providing a useful error message.
    """
    if max_y < REQUIRED_TERM_HEIGHT or max_x < REQUIRED_TERM_WIDTH:
        curses.endwin()
        sys.stderr.write(f"esc requires at least a "

                         f"{REQUIRED_TERM_WIDTH}x{REQUIRED_TERM_HEIGHT} terminal "