def parse_unitname(unitname, fold_scale_prefix=True):

    def copyfields(srcdict, nameprefix):
        fields = ('multiplier', 'unit_class', 'primary_unit', 'base_unit', 'scale_multiplier')
        for f in fields:
            try:
                unitstruct[nameprefix + f] = srcdict[f]
            except KeyError:
                pass

    parts = unitname.split('/', 2)
    if len(parts) > 2 or '' in parts:
        # surrender pathetically and just return the original unit
        return {'multiplier': 1, 'unit_class': None, 'primary_unit': unitname,
                'base_unit': unitname}
    unitstruct = parse_simple_unitname(parts[0], fold_scale_prefix=fold_scale_prefix)
    copyfields(unitstruct, 'numer_')
    if len(parts) == 2:
        denominator = parse_simple_unitname(parts[1], fold_scale_prefix=fold_scale_prefix)
        copyfields(denominator, 'denom_')
        unitstruct['multiplier'] /= denominator['multiplier']
        if unitstruct['unit_class'] is None or denominator['unit_class'] is None:
            unitstruct['unit_class'] = None
        else:
            unitstruct['unit_class'] += '/' + denominator['unit_class']
        unitstruct['primary_unit'] += '/' + denominator['primary_unit']
        unitstruct['base_unit'] += '/' + denominator['base_unit']
        if not fold_scale_prefix:
            unitstruct['scale_multiplier'] /= denominator['scale_multiplier']
    return unitstruct
Parse a unit term with at most two parts separated by / (a numerator and
dataset/ETHPy150Open vimeo/graph-explorer/graph_explorer/unitconv.py/parse_unitname