Beispiel #1
0
def setup_environment():
    global form, snapshot
    cgitb.enable()
    signal.alarm(60)
    form = cgi.FieldStorage()
    parable.prepare_slices()
    parable.prepare_dictionary()
    snapshot = form.getvalue("snapshot", "{{snapshot}}")
    if snapshot == "{{snapshot}}":
        snapshot = open('parable.snapshot', 'r').read()
    bootstrap(snapshot)
Beispiel #2
0
def setup_environment():
    global form, snapshot
    cgitb.enable()
    signal.alarm(60)
    form = cgi.FieldStorage()
    parable.prepare_slices()
    parable.prepare_dictionary()
    snapshot = form.getvalue("snapshot", "{{snapshot}}")
    if snapshot == "{{snapshot}}":
        snapshot = open('parable.snapshot', 'r').read()
    bootstrap(snapshot)
Beispiel #3
0
def revert():
    """revert the session to a clean state (does not load bootstrap)"""
    for i in parable.memory_values:
        parable.memory_values.pop()
    for i in parable.memory_map:
        parable.memory_map.pop()
    for i in parable.dictionary_slices:
        parable.dictionary_slices.pop()
    for i in parable.dictionary_names:
        parable.dictionary_names.pop()
    parable.prepare_slices()
    parable.prepare_dictionary()
Beispiel #4
0
def revert():
    """revert the session to a clean state (does not load bootstrap)"""
    for i in parable.memory_values:
        parable.memory_values.pop()
    for i in parable.memory_map:
        parable.memory_map.pop()
    for i in parable.dictionary_slices:
        parable.dictionary_slices.pop()
    for i in parable.dictionary_names:
        parable.dictionary_names.pop()
    parable.prepare_slices()
    parable.prepare_dictionary()
Beispiel #5
0
def completer(text, state):
    options = [x for x in parable.dictionary_names if x.startswith(text)]
    try:
        return options[state]
    except IndexError:
        return None


if __name__ == '__main__':
    (width, height) = getTerminalSize()

    readline.set_completer(completer)
    readline.parse_and_bind("tab: complete")

    parable.prepare_slices()
    parable.prepare_dictionary()
    parable.parse_bootstrap(open('stdlib.p').readlines())

    try:
        home = expanduser("~")
        src = home + "/.parable/on_startup.p"
        parable.parse_bootstrap(open(src).readlines())
    except:
        pass

    while 1 == 1:
        display(height, width)

        try:
            src = get_input()
        except:
Beispiel #6
0
    except IndexError:
        return None

if __name__ == '__main__':
    print('Parable Listener, (c) 2013-2016 Charles Childers')
    print('------------------------------------------------')
    print('.s       Display Stack')
    print('bye      Exit Listener')
    print('words    Display a list of all named items')
    print('------------------------------------------------\n')

    readline.set_completer(completer)
    readline.parse_and_bind("tab: complete")

    parable.prepare_slices()
    parable.prepare_dictionary()
    if os.path.exists('parable.snapshot'):
        init_from_snapshot(open('parable.snapshot').read())
    else:
        parable.parse_bootstrap(open('stdlib.p').readlines())

    evaluate("[ \"-\"   `9000 ] '.s' :")
    evaluate("[ \"-\"   `9001 ] 'bye' :")
    evaluate("[ \"-\"   `9002 ] 'words' :")
    evaluate("[ \"s-\"  `9003 ] 'include' :")

    try:
        home = expanduser("~")
        src = home + "/.parable/on_startup.p"
        parable.parse_bootstrap(open(src).readlines())
    except:
Beispiel #7
0
def prepare():
    parable.prepare_slices()
    parable.prepare_dictionary()
    parable.parse_bootstrap(open('stdlib.p').readlines())