Example #1
0
def run_tool(editor):
    from parser import parse, ParseException

    if not tools:
        try:
            tools[:] = parse(open(join_to_settings_dir('external.tools')).read())
        except IOError:
            pass
        except ParseException, e:
            editor.message(str(e), 5000)
            return
Example #2
0
def edit_external_tools(editor):
    import shutil
    from os.path import join, exists, dirname
    from snaked.util import make_missing_dirs

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

    e = editor.open_file(filename)
    e.connect('file-saved', on_external_tools_save)
Example #3
0
    def edit_context(self, ctx):
        user_snippet_filename = join_to_settings_dir('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)
Example #4
0
def discover_snippet_contexts():
    dirs_to_scan = [
        os.path.join(os.path.dirname(__file__), 'snippets'),
        join_to_settings_dir('snippets'),
    ]

    for d in dirs_to_scan:
        if os.path.exists(d):
            for name in os.listdir(d):
                path = os.path.join(d, name)
                nm, ext = os.path.splitext(name)
                if ext == '.snippets' and os.path.isfile(path):
                    existing_snippet_contexts[nm] = path
Example #5
0
def get_settings_path(name):
    filename = join_to_settings_dir(name)
    make_missing_dirs(filename)
    return filename