Exemplo n.º 1
0
def normalize_number_nervalue(val_string):
    m = re.search(r'\d+(\.\d+)*', val_string)
    if m is None:
        return None
    string = m.group()
    val = evaluator.to_value(string)
    if isinstance(val, evaluator.NumberValue):
        return val.amount
    else:
        return None
Exemplo n.º 2
0
def normalize_date_nervalue(val_string):
    if re.match('\A[\d]{4}$', val_string):
        string = val_string + '-XX-XX'
    elif re.match('\A[\dX]{4}-[\dX]{2}$', val_string):
        string = val_string + '-XX'
    else:
        string = val_string
    val = evaluator.to_value(string)
    if isinstance(val, evaluator.DateValue):
        return val.normalized
    else:
        return None