def screenshot_init( sizes, keys ):
    """
    Replace curses_display.Screen and raw_display.Screen class with 
    HtmlGenerator.
    
    Call this function before executing an application that uses 
    curses_display.Screen to have that code use HtmlGenerator instead.
    
    sizes -- list of ( columns, rows ) tuples to be returned by each call
             to HtmlGenerator.get_cols_rows()
    keys -- list of lists of keys to be returned by each call to
            HtmlGenerator.get_input()
    
    Lists of keys may include "window resize" to force the application to
    call get_cols_rows and read a new screen size.

    For example, the following call will prepare an application to:
     1. start in 80x25 with its first call to get_cols_rows()
     2. take a screenshot when it calls draw_screen(..)
     3. simulate 5 "down" keys from get_input()
     4. take a screenshot when it calls draw_screen(..)
     5. simulate keys "a", "b", "c" and a "window resize"
     6. resize to 20x10 on its second call to get_cols_rows()
     7. take a screenshot when it calls draw_screen(..)
     8. simulate a "Q" keypress to quit the application

    screenshot_init( [ (80,25), (20,10) ],
        [ ["down"]*5, ["a","b","c","window resize"], ["Q"] ] )
    """
    try:
        for (row,col) in sizes:
            assert type(row) == int
            assert row>0 and col>0
    except (AssertionError, ValueError):
        raise Exception, "sizes must be in the form [ (col1,row1), (col2,row2), ...]"
    
    try:
        for l in keys:
            assert type(l) == list
            for k in l:
                assert type(k) == str
    except (__HOLE__, ValueError):
        raise Exception, "keys must be in the form [ [keyA1, keyA2, ..], [keyB1, ..], ...]"
    
    import curses_display
    curses_display.Screen = HtmlGenerator
    import raw_display
    raw_display.Screen = HtmlGenerator
    
    HtmlGenerator.sizes = sizes
    HtmlGenerator.keys = keys
dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/html_fragment.py/screenshot_init