def parse_residue_spec(resspec):
    """
    Light version of:
    vermouth.processors.annotate_mud_mod.parse_residue_spec

    Parse a residue specification:
    <mol_name>#<mol_idx>-<resname>#<resid>

    Returns a dictionary with keys 'mol_name',
    'mol_idx', and 'resname' for the fields that are specified.
    Resid will be an int.

    Parameters
    ----------
    resspec: str
    Returns
    -------
    dict
    """
    molname = None
    resname = None
    mol_idx = None
    resid = None
    mol_name_idx, *res = resspec.split('-', 1)
    molname, *mol_idx = mol_name_idx.split('#', 1)

    if res:
        resname, *resid = res[0].split('#', 1)

    error_msg = ('Your selection {} is invalid. Was not able to assign {}'
                 'with value {}')

    out = {}
    if mol_idx:

        try:
           mol_idx = int(mol_idx[0])
        except ValueError:
           raise IOError(error_msg.format(resspec, 'mol_idx', mol_idx))

        out['mol_idx'] = mol_idx

    if resname:
        out['resname'] = resname
    if molname:
        out['molname'] = molname
    if resid:
        try:
           out['resid'] = float(resid[0])
        except ValueError:
           raise IOError(error_msg.format(resspec, 'mol_idx', mol_idx))

    return out