<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _assign_IDS_to_datafiles(datafiles, parser, measurement_class=None, **kwargs):
 """ Assign measurement IDS to datafiles using specified parser. Parameters datafiles : iterable of str Path to datafiles. An ID will be assigned to each. Note that this function does not check for uniqueness of IDs! {_bases_filename_parser} measurement_class: object Used to create a temporary object when reading the ID from the datafile. The measurement class needs to have an `ID_from_data` method. Only used when parser='read'. kwargs: dict Additional parameters to be passed to parser is it is a callable, or 'read'. If parser is 'read', kwargs are passed to the measurement class's `ID_from_data` method. Returns ------- Dict of ID:datafile """

    if isinstance(parser, collections.Mapping):
        fparse = lambda x: parser[x]
    elif hasattr(parser, '__call__'):
        fparse = lambda x: parser(x, **kwargs)
    elif parser == 'name':
        kwargs.setdefault('pre', 'Well_')
        kwargs.setdefault('post', ['_', '\.', '$'])
        kwargs.setdefault('tagtype', str)
        fparse = lambda x: get_tag_value(os.path.basename(x), **kwargs)
    elif parser == 'number':
        fparse = lambda x: int(x.split('.')[-2])
    elif parser == 'read':
        fparse = lambda x: measurement_class(ID='temporary', datafile=x).ID_from_data(**kwargs)
    else:
        raise ValueError('Encountered unsupported value "%s" for parser parameter.' % parser)
    d = dict((fparse(dfile), dfile) for dfile in datafiles)
    return d