Example #1
0
# version 3 of the License, or (at your option) any later version.

"""Search on DuckDuckGo"""

import logging
import re

import sublime

import suricate

from . import popup_util
from . import sublime_wrapper
from .thirdparty import duckduckgo2html

suricate.reload_module(popup_util)
suricate.reload_module(sublime_wrapper)
suricate.reload_module(duckduckgo2html)


DDG_USERAGENT = 'sublime-suricate'


def get_answer(query, scope=None, **kwargs):
    suricate.debuglog('searching %r using scope %r...', query, scope)
    try:
        html = ''

        if scope and scope.lower() != query.lower():
            scoped_kwargs = dict(kwargs)
            scoped_kwargs['hide_headers'] = True
Example #2
0
# Sublime Suricate Copyright (C) 2013 N. Subiron
#
# This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
# are welcome to redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.

"""Search online"""

import suricate

from . import popup_util

suricate.reload_module(popup_util)


# @todo get more, add to settings?
ENGINES = {
    'DuckDuckGo': 'https://duckduckgo.com/?q=',
    'Google': 'https://www.google.com/search?q='
}


def show(view, window, caption=None, engine=None):
    engine = _get_default_engine_if_not_valid(engine)
    prefix = ENGINES[engine]
    if not caption:
        caption = '%s:' % engine
    selected_words = popup_util.SelectedWords.make(view, extend_to_words=False)
    initial_text = selected_words.words if selected_words else ''
    on_done = lambda string: _on_done(prefix, string, window)
Example #3
0
#
# This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
# are welcome to redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.

import os

import sublime

import suricate

from . import process
from . import sublime_wrapper

suricate.reload_module(process)
suricate.reload_module(sublime_wrapper)


def _get_path_prefix(window):
    variables = suricate.extract_variables(window)
    return os.path.abspath(os.path.join(variables["file_path"], variables["file_base_name"]))


def clean(window=None):
    """Remove LaTeX temporary files."""
    temp_extensions = [
        ".log",
        ".aux",
        ".dvi",
        ".lof",
Example #4
0
# This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
# are welcome to redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.

import os
import sublime

import suricate

from . import osutil
from . import process
from . import sublime_wrapper
from . import vcs_parser

suricate.reload_module(osutil)
suricate.reload_module(process)
suricate.reload_module(sublime_wrapper)
suricate.reload_module(vcs_parser)

SourceControlFileBaseName = 'SuricateVCS.json'


def _do(cmd, caption, path, out=None, ask=None, **kwargs):
    working_dir, base_name = os.path.split(
        path) if os.path.isfile(path) else (path, '.')
    cmd = suricate.expand_variables(cmd, {'path': base_name})
    suricate.debuglog('vcs do: %s', ' '.join(cmd))
    if ask and not sublime.ok_cancel_dialog(
        suricate.expand_variables(
            ask, {