How to use the aria2p.interface function in aria2p

To help you get started, we’ve selected a few aria2p examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pawamoy / aria2p / tests / test_interface.py View on Github external
def get_interface(patcher, api=None, events=None, append_q=True):
    if not events:
        events = []

    if append_q:
        events.append(KeyboardEvent(ord("q")))

    class MockedManagedScreen:
        def __enter__(self):
            return MockedScreen(events)

        def __exit__(self, exc_type, exc_val, exc_tb):
            pass

    patcher.setattr(tui, "ManagedScreen", MockedManagedScreen)
    return tui.Interface(api=api)
github pawamoy / aria2p / tests / test_interface.py View on Github external
RESIZE = 1
    PASS_N_FRAMES = 2
    PASS_N_TICKS = 3
    RAISE = 4

    def __init__(self, event_type, value=None):
        self.type = event_type
        self.value = value


class Event:
    resize = SpecialEvent(SpecialEvent.RESIZE)
    pass_frame = SpecialEvent(SpecialEvent.PASS_N_FRAMES, 1)
    pass_tick = SpecialEvent(SpecialEvent.PASS_N_TICKS, 1)
    pass_half_tick = SpecialEvent(SpecialEvent.PASS_N_FRAMES, tui.Interface.frames / 2)
    pass_tick_and_a_half = SpecialEvent(SpecialEvent.PASS_N_FRAMES, tui.Interface.frames * 3 / 2)
    up = KeyboardEvent(Screen.KEY_UP)
    down = KeyboardEvent(Screen.KEY_DOWN)
    left = KeyboardEvent(Screen.KEY_LEFT)
    right = KeyboardEvent(Screen.KEY_RIGHT)
    delete = KeyboardEvent(Screen.KEY_DELETE)
    esc = KeyboardEvent(Screen.KEY_ESCAPE)
    f1 = KeyboardEvent(Screen.KEY_F1)
    f2 = KeyboardEvent(Screen.KEY_F2)
    f3 = KeyboardEvent(Screen.KEY_F3)
    f4 = KeyboardEvent(Screen.KEY_F4)
    f5 = KeyboardEvent(Screen.KEY_F5)
    f6 = KeyboardEvent(Screen.KEY_F6)
    f7 = KeyboardEvent(Screen.KEY_F7)
    f8 = KeyboardEvent(Screen.KEY_F8)
    f9 = KeyboardEvent(Screen.KEY_F9)
    f10 = KeyboardEvent(Screen.KEY_F10)