def assignNillableDouble(variable, pattern, text, line, mandatory=False):
    floatPattern = re.compile(
        r'(?P<float>[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)', re.IGNORECASE)
    ok = re.match(pattern, text)
    if ok:
        value = ok.group('value').strip()
        if value:
            ok = re.search(floatPattern, value)
            if ok:
                floatValue = ok.group('float')
                if len(floatValue) < len(value):
                    message = "Only the double decimal '" + floatValue + "' have been extracted, else discarded"
                    infoMessage(line, text, message)
                variable[0] = geo.NillableDouble(float(floatValue))
            else:
                errorMessage(line, value, "A double decimal is expected")
                variable[0] = geo.NillableDouble()
                variable[0]._setIsNil()
        else:
            variable[0] = geo.NillableDouble()
            variable[0]._setIsNil()
            errorMessage(line, "", "A double decimal is expected")
        return True
    else:
        return False
def setNillableDoubleAttribute(target,
                               field,
                               pattern,
                               text,
                               line,
                               mandatory=True,
                               output=True):
    floatPattern = re.compile(
        r'(?P<float>[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)', re.IGNORECASE)
    nonePattern = re.compile(r'none', re.IGNORECASE)
    ok = re.match(pattern, text)
    if ok:
        value = ok.group('value').strip()
        if value:
            bracketedFloatPattern = re.compile(
                r'\(.*(?P<float>[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?).*\)',
                re.IGNORECASE)
            # for a very special case as:            Marker->ARP East Ecc(m)  : (F8.4)
            # you should NOT extract '8.4' as the double value
            special = re.match(bracketedFloatPattern, value)
            if special:
                ok = False
            else:
                ok = re.search(floatPattern, value)

            if ok:
                floatValue = ok.group('float')
                if len(floatValue) < len(value):
                    if output:
                        message = "Only the double decimal '" + str(
                            float(floatValue)
                        ) + "' have been extracted, else discarded"
                        infoMessage(line, text, message)
                nilDouble = geo.NillableDouble(float(floatValue))
                setattr(target, field, nilDouble)
            else:
                if mandatory:
                    nilDouble = geo.NillableDouble()
                    nilDouble._setIsNil()
                    setattr(target, field, nilDouble)
                    if output:
                        errorMessage(line, value,
                                     "A double decimal is expected")
                else:
                    ok = re.match(nonePattern, value)
                    if not ok:
                        if output:
                            errorMessage(line, value,
                                         "A double decimal is expected")
        else:
            if mandatory:
                nilDouble = geo.NillableDouble()
                nilDouble._setIsNil()
                setattr(target, field, nilDouble)
                if output:
                    errorMessage(line, "", "A double decimal is expected")
        return True
    else:
        return False