alfred/Alfred.alfredpreferences/workflows/user.workflow.99DE3F5C-7CB4-4E0B-9195-7782AADC167B/converter/safe_math.py
def safe_eval(query):
    '''safely evaluate a query while automatically evaluating some mathematical
    functions

    >>> safe_eval('.1 * 0.01')
    Decimal('0.001')
    >>> safe_eval('0x10')
    Decimal('16')
    >>> safe_eval('10')
    Decimal('10')
    >>> safe_eval('010')
    Decimal('8')
    >>> safe_eval('0b10')
    Decimal('2')
    '''
    query = HEX_RE.sub(HEX_REPLACE, query)
    query = BIN_RE.sub(BIN_REPLACE, query)
    query = OCT_RE.sub(OCT_REPLACE, query)
    query = DECIMAL_RE.sub(DECIMAL_REPLACE, query)
    query = AUTOMUL_RE.sub(AUTOMUL_REPLACE, query)
    query = fix_partial_queries(query)
    query = fix_parentheses(query)

    for k, v in constants.PRE_EVAL_REPLACEMENTS.items():
        query = query.replace(k, v)

    try:
        return eval(query, {'__builtins__': None}, safe_dict)
    except SyntaxError as e:
        raise SyntaxErr(e)
safely evaluate a query while automatically evaluating some mathematical
    functions

    >>> safe_eval('.1 * 0.01')
    Decimal('0.001')
    >>> safe_eval('0x10')
    Decimal('16')
    >>> safe_eval('10')
    Decimal('10')
    >>> safe_eval('010')
    Decimal('8')
    >>> safe_eval('0b10')
    Decimal('2')
    
safely evaluate a query while automatically evaluating some mathematical
functions


safely evaluate a query while automatically evaluating some mathematical functions
def safe_eval(query):
    query = HEX_RE.sub(HEX_REPLACE, query)
    query = BIN_RE.sub(BIN_REPLACE, query)
    query = OCT_RE.sub(OCT_REPLACE, query)
    query = DECIMAL_RE.sub(DECIMAL_REPLACE, query)
    query = AUTOMUL_RE.sub(AUTOMUL_REPLACE, query)
    query = fix_partial_queries(query)
    query = fix_parentheses(query)
    for k, v in constants.PRE_EVAL_REPLACEMENTS.items():
        query = query.replace(k, v)
    try:
        return eval(query, {'__builtins__': None}, safe_dict)
    except SyntaxError as e:
        raise SyntaxErr(e)
def safe_eval ( query ) : query = HEX_RE . sub ( HEX_REPLACE , query ) query = BIN_RE . sub ( BIN_REPLACE , query ) query = OCT_RE . sub ( OCT_REPLACE , query ) query = DECIMAL_RE . sub ( DECIMAL_REPLACE , query ) query = AUTOMUL_RE . sub ( AUTOMUL_REPLACE , query ) query = fix_partial_queries ( query ) query = fix_parentheses ( query ) for k , v in constants . PRE_EVAL_REPLACEMENTS . items ( ) : query = query . replace ( k , v ) try : return eval ( query , { '__builtins__' : None } , safe_dict ) except SyntaxError as e : raise SyntaxErr ( e )
safely evaluate a query while automatically evaluating some mathematical
functions
safely evaluate a query while automatically evaluating some mathematical functions
'''safely evaluate a query while automatically evaluating some mathematical
    functions

    >>> safe_eval('.1 * 0.01')
    Decimal('0.001')
    >>> safe_eval('0x10')
    Decimal('16')
    >>> safe_eval('10')
    Decimal('10')
    >>> safe_eval('010')
    Decimal('8')
    >>> safe_eval('0b10')
    Decimal('2')
    '''
query