Accept a string representing link propagation delay (e.g., 
    '100 milliseconds' or '100 msec' or 100 millisec') and return
    a floating point number representing the delay in seconds.
    Recognizes:
        - us, usec, micros* all as microseconds
        - ms, msec, millisec* all as milliseconds
        - s, sec* as seconds

    returns None on parse failure.

def unhumanize_delay(delaystr):
    '''
    Accept a string representing link propagation delay (e.g., 
    '100 milliseconds' or '100 msec' or 100 millisec') and return
    a floating point number representing the delay in seconds.
    Recognizes:
        - us, usec, micros* all as microseconds
        - ms, msec, millisec* all as milliseconds
        - s, sec* as seconds

    returns None on parse failure.
    '''
    if isinstance(delaystr, float):
        return delaystr

    mobj = re.match('^\s*([\d\.]+)\s*(\w*)', delaystr)
    if not mobj:
        return None
    value, units = mobj.groups()
    value = float(value)
    if not units:
        divisor = 1.0
    elif units == 'us' or units == 'usec' or units.startswith('micros'):
        divisor = 1e6
    elif units == 'ms' or units == 'msec' or units.startswith('millis'):
        divisor = 1e3
    elif units == 's' or units.startswith('sec'):
        divisor = 1.0
    else:
        return None
    return value / divisor