Beispiel #1
0
def slack_message():
    results = find_and_calc(request.args.get("text", request.form.get("text", "")))
    if results:
        response = {"text": "\n".join("`%s = %s`" % (formula, result) for formula, result in results)}
    else:
        response = {"msg": "No formulas found."}

    return json.dumps(response)
Beispiel #2
0
def lambda_handler(params, context):
    results = find_and_calc(params['text'])
    logging.info('Found %d formulas in text "%s" --> %s', len(results or []),
                 params['text'], results)

    if results:
        return {
            'text':
            '\n'.join('`%s = %s`' % (formula, result)
                      for formula, result in results)
        }

    return None
Beispiel #3
0
def slack_message():
    results = find_and_calc(
        request.args.get('text', request.form.get('text', '')))
    if results:
        response = {
            'text':
            '\n'.join('`%s = %s`' % (formula, result)
                      for formula, result in results)
        }
    else:
        response = {'msg': 'No formulas found.'}

    return json.dumps(response)
Beispiel #4
0
def lambda_handler(params, context):
    results = find_and_calc(params['text'])
    logging.info(
        'Found %d formulas in text "%s" --> %s',
        len(results or []), params['text'], results)

    if results:
        return {
            'text': '\n'.join(
                '`%s = %s`' % (formula, result)
                for formula, result in results
            )
        }

    return None
Beispiel #5
0
#!/usr/bin/env python
"""For quick testing on cmdline, you can run this file with arguments to be
parsed as text for formulas, like:
    python cmdline.py 'What is 1 + 2?'
"""
from sys import argv

from calc import find_and_calc

if __name__ == '__main__':
    for arg in argv[1:]:
        print '==] %s' % arg
        for index, (formula, result) in enumerate(find_and_calc(arg) or []):
            print '  #%d  %s  --> %s' % (index + 1, formula, result)
Beispiel #6
0
#!/usr/bin/env python
"""For quick testing on cmdline, you can run this file with arguments to be
parsed as text for formulas, like:
    python cmdline.py 'What is 1 + 2?'
"""
from sys import argv

from calc import find_and_calc


if __name__ == '__main__':
    for arg in argv[1:]:
        print '==] %s' % arg
        for index, (formula, result) in enumerate(find_and_calc(arg) or []):
            print '  #%d  %s  --> %s' % (index + 1, formula, result)