def adjustUnits(v, total=None, dpi=300, default_unit='pt', emsize=10):
    """Takes something like 2cm and returns 2*cm.

    If you use % as a unit, it returns the percentage of "total".

    If total is not given, returns a percentage of the page width.
    However, if you get to that stage, you are doing it wrong.

    Example::

            >>> adjustUnits('50%',200)
            100

    """

    if v is None or v=="":
        return None

    v = str(v)
    l = re.split('(-?[0-9\.]*)', v)
    n=l[1]
    u=default_unit
    if len(l) == 3 and l[2]:
        u=l[2]
    if u in units.__dict__:
        return float(n) * units.__dict__[u]
    else:
        if u == '%':
            return float(n) * total/100
        elif u=='px':
            return float(n) * units.inch / dpi
        elif u=='pt':
            return float(n)
        elif u=='in':
            return float(n) * units.inch
        elif u=='em':
            return float(n) * emsize
        elif u=='ex':
            return float(n) * emsize /2
        elif u=='pc': # picas!
            return float(n) * 12
        log.error(u % 'Unknown unit "%s"')
    return float(n)
dataset/ETHPy150Open rst2pdf/rst2pdf/rst2pdf/styles.py/adjustUnits/swapped operands of `%`