Ejemplo n.º 1
0
def show_contexts_config(window, config_type):
    import shutil
    from os.path import join, exists, dirname
    from uxie.utils import make_missing_dirs

    manager = window.manager

    if config_type == "default":
        processor = manager.default_ctx_processor
    elif config_type == "session":
        processor = manager.session_ctx_processor
    elif config_type == "project":
        editor = window.get_editor_context()
        if not editor:
            window.message("Hmm. Project?", "warn")
            return

        root = editor.project_root
        if not root:
            editor.message("Current project root is not defined", "warn")
            return

        processor = manager.get_context_manager(root).project_processor
    else:
        raise Exception("Unknown context config type: " + str(config_type))

    uri = processor.filename
    if not exists(uri):
        make_missing_dirs(uri)
        shutil.copy(join(dirname(__file__), "contexts.template"), uri)

    e = window.manager.open(uri)
    window.attach_editor(e)
    e.connect("file-saved", on_context_saved)
Ejemplo n.º 2
0
    def edit_context(self, ctx):
        user_snippet_filename = join_to_settings_dir('snaked', 'snippets', ctx + '.snippets')
        if ctx in self.existing_snippets and \
                self.existing_snippets[ctx] != user_snippet_filename:

            import shutil
            make_missing_dirs(user_snippet_filename)
            shutil.copy(self.existing_snippets[ctx], user_snippet_filename)

        idle(self.hide)
        e = self.editor().open_file(user_snippet_filename)
        e.connect('file-saved', on_snippet_saved, ctx)
Ejemplo n.º 3
0
def edit_external_tools(editor, kind):
    if kind == 'global':
        filename = join_to_settings_dir('snaked', 'tools.conf')
    elif kind == 'session':
        filename = join_to_settings_dir('snaked', editor.session, 'tools')
    else:
        raise Exception('Unknown external tools type: ' + str(kind))

    if not exists(filename):
        make_missing_dirs(filename)
        shutil.copy(join(dirname(__file__), 'external.tools.template'), filename)

    e = editor.window.manager.open(filename, contexts='python')
    editor.window.attach_editor(e)
    e.connect('file-saved', on_external_tools_save)
Ejemplo n.º 4
0
def get_settings_path(*name):
    filename = join_to_settings_dir("snaked", *name)
    make_missing_dirs(filename)
    return filename