Beispiel #1
0
def prepareErrorMessage(message):
    """
    Prepare error messae

    :param str message: Message

    :return str
    """
    item = Item(id=__prettyname__, icon=icon_path)
    item.text = __prettyname__
    item.subtext = message
    return item
Beispiel #2
0
def handleQuery(query):
    if not query.isTriggered:
        return

    item = Item(completion=query.rawString, icon=ICON_PATH)
    stripped = query.string.strip()

    if stripped:
        with NamedTemporaryFile() as f:
            f.write(bytes(stripped, 'utf-8'))
            f.flush()
            output = subprocess.check_output(
                ['wolframscript', '-print', '-f', f.name])
        result = str(output.strip(), 'utf-8')
        item.text = result
        item.subtext = 'Result'
        item.addAction(ClipAction('Copy result to clipboard', result))
    else:
        item.text = ''
        item.subtext = 'Type a Mathematica expression'

    return item
Beispiel #3
0
def prepareResultsItem(query, result):
    """
    Prepare resuls item

    :param str query : Query
    :param str result: Result

    :return Item
    """
    value = result.decode('utf-8').split(' ')[0]
    item = Item(id=__prettyname__, icon=icon_path, completion=query.rawString)
    item.text = value
    item.subtext = result
    item.addAction(ClipAction("Copy result to clipboard", value))
    return item