bomlib/units.py
def compMatch(component):
    """
    Return a normalized value and units for a given component value string
    e.g. compMatch("10R2") returns (10, R)
    e.g. compMatch("3.3mOhm") returns (0.0033, R)
    """

    # Remove any commas
    component = component.strip().replace(",", "").lower()

    match = matchString()

    result = re.search(match, component)

    if not result:
        return None

    if not len(result.groups()) == 4:
        return None

    value, prefix, units, post = result.groups()

    # Special case where units is in the middle of the string
    # e.g. "0R05" for 0.05Ohm
    # In this case, we will NOT have a decimal
    # We will also have a trailing number

    if post and "." not in value:
        try:
            value = float(int(value))
            postValue = float(int(post)) / (10 ** len(post))
            value = value * 1.0 + postValue
        except:
            return None

    try:
        val = float(value)
    except:
        return None

    val = "{0:.15f}".format(val * 1.0 * getPrefix(prefix))

    return (val, getUnit(units))

    Return a normalized value and units for a given component value string
    e.g. compMatch("10R2") returns (10, R)
    e.g. compMatch("3.3mOhm") returns (0.0033, R)
    
Return a normalized value and units for a given component value string
e.g.
Return a normalized value and units for a given component value string e . g .
def compMatch(component):
    component = component.strip().replace(",", "").lower()
    match = matchString()
    result = re.search(match, component)
    if not result:
        return None
    if not len(result.groups()) == 4:
        return None
    value, prefix, units, post = result.groups()
    if post and "." not in value:
        try:
            value = float(int(value))
            postValue = float(int(post)) / (10 ** len(post))
            value = value * 1.0 + postValue
        except:
            return None
    try:
        val = float(value)
    except:
        return None
    val = "{0:.15f}".format(val * 1.0 * getPrefix(prefix))
    return (val, getUnit(units))
def compMatch ( component ) : component = component . strip ( ) . replace ( "," , "" ) . lower ( ) match = matchString ( ) result = re . search ( match , component ) if not result : return None if not len ( result . groups ( ) ) == 4 : return None value , prefix , units , post = result . groups ( ) if post and "." not in value : try : value = float ( int ( value ) ) postValue = float ( int ( post ) ) / ( 10 ** len ( post ) ) value = value * 1.0 + postValue except : return None try : val = float ( value ) except : return None val = "{0:.15f}" . format ( val * 1.0 * getPrefix ( prefix ) ) return ( val , getUnit ( units ) )
Return a normalized value and units for a given component value string
e.g.
Return a normalized value and units for a given component value string e . g .
"""
    Return a normalized value and units for a given component value string
    e.g. compMatch("10R2") returns (10, R)
    e.g. compMatch("3.3mOhm") returns (0.0033, R)
    """ # Remove any commas # Special case where units is in the middle of the string # e.g. "0R05" for 0.05Ohm # In this case, we will NOT have a decimal # We will also have a trailing number
component