Esempio n. 1
0
def init(injector):
    injector.add_context('python-editor', 'editor-active',
        lambda e: e if is_python_editor(e) else None)

    injector.bind('python-editor', 'goto-definition', '_Python#70/Goto _defenition', goto_definition)
    injector.bind('python-editor', 'show-outline', 'Python/Show _outline', open_outline)

    injector.bind('python-editor', 'show-calltip', 'Python/Show _calltip', show_calltips)

    injector.bind_dynamic('python-editor', 'select-interpreter', 'Python/_Executable/executables',
        generate_python_executable_menu, resolve_python_executable_menu_entry, True)

    injector.bind('editor', 'run-test', 'Python/_Tests/_Run test in cursor scope', run_test)
    injector.bind('editor', 'run-all-tests', 'Python/Tests/Run _all tests', run_all_tests)
    injector.bind('editor', 'rerun-test', 'Python/Tests/Rerun last test', rerun_test)
    injector.bind('editor', 'toggle-test-panel', 'View/Toggle _test panel', toggle_test_panel)

    from snaked.core.prefs import add_option, add_internal_option

    add_internal_option('PYTHON_EXECUTABLE', 'default')
    add_option('PYTHON_EXECUTABLES', dict,
        'Path to python executables. Used by test runner and completion framework')
    add_option('PYTHON_EXECUTABLE_ENV', dict,
        'Python interpreter environment. Used by test runner and completion framework')
    add_option('PYTHON_SUPP_CONFIG', dict, 'Config for supplement')

    add_option('PYTHON_SPYPKG_HANDLER_MAX_CHARS', 25, 'Maximum allowed python package title length')

    add_option('PYTHON_LINT_ON_FILE_LOAD', False, 'Run lint check on file load')

    from snaked.core.titler import add_title_handler
    add_title_handler('pypkg', pypkg_handler)
    add_title_handler('spypkg', spypkg_handler)

    injector.on_ready('editor-with-new-buffer-created', editor_created)
    injector.on_ready('editor-with-new-buffer', editor_opened)
    injector.on_ready('manager', start_supplement)
    injector.on_done('last-buffer-editor', editor_closed)
    injector.on_done('manager', quit)
Esempio n. 2
0
from snaked.core.titler import create_fsm, add_title_handler

def hempty(name):
    return None

def hid(name):
    return name

def hq(name):
    return '"%s"' % ( name if name else None)

add_title_handler('hid', hid)
add_title_handler('hq', hq)
add_title_handler('hempty', hempty)

def test_simple_handler():
    fsm = create_fsm("%hq")
    result = fsm('aaa')
    assert result == '"aaa"'

def test_no_handler():
    fsm = create_fsm("str")
    result = fsm('aaa')
    assert result == 'str'

def test_alt_handler():
    fsm = create_fsm("{%hid|sss}")

    result = fsm(None)
    assert result == 'sss'
Esempio n. 3
0
 def add_title_handler(self, name, callback):
     from snaked.core.titler import add_title_handler
     add_title_handler(name, callback)