Example #1
0
def money(n):
    if v.money(n):
        money = re.sub(r'[\,]', '', n)
        return {'currency' : money[0], 'amount' : float(money[1:])}

    else:
        return None
Example #2
0
def money(string):
    money_dict = {}
    if not v.money(string):
        return None
    money_dict['currency'] = string[0]
    ret = re.sub(r'[^0-9\.]', '', string)
    money_dict['amount'] = float(ret[0:])
    return money_dict
Example #3
0
def money(s):
    if v.money(s):
        ret = {}
        dollars = re.sub(r'[\$,]', '', s)
        ret['currency'] = '$'
        ret['amount'] = float(dollars)
        return ret
    else:
        return None
def money(x):
    if v.money(x):
        money = re.sub(r'[^\$0-9.]', '', x)
        if '.' in money:
            return {'currency': money[0], 'amount': float(money[1:])}
        else:
            new_money = money+'.0'
            return {'currency': new_money[0], 'amount':float(new_money[1:])}
    else:
        return None
Example #5
0
def test_money():
    """We are just concerned with dollars here."""

    assert v.money("$4")
    assert v.money("$19")
    assert v.money("$19.00")
    assert v.money("$3.58")
    assert v.money("$1000")
    assert v.money("$1000.00")
    assert v.money("$1,000")
    assert v.money("$1,000.00")
    assert v.money("$5,555,555")
    assert v.money("$5,555,555.55")
    assert v.money("$45,555,555.55")
    assert v.money("$456,555,555.55")
    assert v.money("$1234567.89")
    assert not v.money("")
    assert not v.money("$12,34")
    assert not v.money("$1234.9")
    assert not v.money("$1234.999")
    assert not v.money("$")
    assert not v.money("31")
    assert not v.money("$$31")
def money(x):
    if val.money(x):
        money = re.sub(r'[,]', '', x)
        return {"currency" : "$", "amount" : float(money[1:])}
Example #7
0
def test_money():
    """We are just concerned with dollars here."""

    assert v.money("$4")
    assert v.money("$19")
    assert v.money("$19.00")
    assert v.money("$3.58")
    assert v.money("$1000")
    assert v.money("$1000.00")
    assert v.money("$1,000")
    assert v.money("$1,000.00")
    assert v.money("$5,555,555")
    assert v.money("$5,555,555.55")
    assert v.money("$45,555,555.55")
    assert v.money("$456,555,555.55")
    assert v.money("$1234567.89")
    assert not v.money("")
    assert not v.money("$12,34")
    assert not v.money("$1234.9")
    assert not v.money("$1234.999")
    assert not v.money("$")
    assert not v.money("31")
    assert not v.money("$$31")
def money(input):
    if v.money(input):
        mon = re.sub(r'[\,]', '', input)
        return {'currency' : mon[0], 'amount' : float(mon[1:])}
def money(number):
    if v.money(number):
        mon = re.sub(r'[\,]', '', number)
        return {'currency': mon[0], 'amount': float(mon[1:])}