def parse_unitname(unitname, fold_scale_prefix=True):
    """
    Parse a unit term with at most two parts separated by / (a numerator and
    denominator, or just a plain term). Returns a structure identical to that
    returned by parse_simple_unitname(), but with extra fields for the
    numerator and for the denominator, if one exists.

    If there is a denominator, the 'base_unit', 'unit_class', 'primary_unit',
    'multiplier', and 'scale_multiplier' fields will be returned as
    combinations of the corresponding fields for the numerator and the
    denominator.

    >>> parse_unitname('GB/h') == {
    ...     'numer_multiplier': 1e9 * 9, 'denom_multiplier': 3600,
    ...     'multiplier': 1e9 * 8 / 3600,
    ...     'numer_unit_class': 'datasize', 'denom_unit_class': 'time',
    ...     'unit_class': 'datasize/time',
    ...     'numer_primary_unit': 'b', 'denom_primary_unit': 's',
    ...     'primary_unit': 'b/s',
    ...     'numer_base_unit': 'B', 'denom_base_unit': 'h',
    ...     'base_unit': 'B/h'}
    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 __HOLE__:
                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
dataset/ETHPy150Open vimeo/graph-explorer/graph_explorer/unitconv.py/parse_unitname