'Given a simple list of files names, determine the files that constitute
a valid fileset i.e. a set of files that defines the state of an
object, and determine the files that are obsolete and could be deleted.
Note that some files may fall into neither category.
If a file is considered part of a valid fileset then its info dict will
be added to the results dict, keyed by <extension>_info. Any files that
are no longer required will have their info dicts added to a list
stored under the key \'obsolete\'.
The results dict will always contain entries with keys \'ts_file\',
\'data_file\' and \'meta_file\'. Their values will be the fully qualified
path to a file of the corresponding type if there is such a file in the
valid fileset, or None.
:param files: a list of file names.
:param datadir: directory name files are from.
:param verify: if True verify that the ondisk file contract has not
been violated, otherwise do not verify.
:returns: a dict that will contain keys:
ts_file   -> path to a .ts file or None
data_file -> path to a .data file or None
meta_file -> path to a .meta file or None
ctype_file -> path to a .meta file or None
and may contain keys:
ts_info   -> a file info dict for a .ts file
data_info -> a file info dict for a .data file
meta_info -> a file info dict for a .meta file
ctype_info -> a file info dict for a .meta file which
contains the content-type value
unexpected -> a list of file paths for unexpected
files
possible_reclaim -> a list of file info dicts for possible
reclaimable files
obsolete  -> a list of file info dicts for obsolete files'

def get_ondisk_files(self, files, datadir, verify=True, **kwargs):

    results = {}
    exts = defaultdict(list)
    for afile in files:
        try:
            file_info = self.parse_on_disk_filename(afile)
            file_info['filename'] = afile
            exts[file_info['ext']].append(file_info)
        except DiskFileError as e:
            file_path = os.path.join((datadir or ''), afile)
            results.setdefault('unexpected', []).append(file_path)
            if RE_RSYNC_TEMPFILE.match(afile):
                self.logger.debug('Rsync    tempfile:    %s', file_path)
            else:
                self.logger.warning('Unexpected    file    %s:    %s', file_path, e)
    for ext in exts:
        exts[ext] = sorted(exts[ext], key=(lambda info: info['timestamp']), reverse=True)
    if exts.get('.ts'):
        for ext in filter((lambda ext: (ext != '.ts')), exts.keys()):
            (exts[ext], older) = self._split_gt_timestamp(exts[ext], exts['.ts'][0]['timestamp'])
            results.setdefault('obsolete', []).extend(older)
        results.setdefault('obsolete', []).extend(exts['.ts'][1:])
        exts['.ts'] = exts['.ts'][:1]
    if exts.get('.meta'):
        retain = 1
        if exts['.meta'][1:]:
            exts['.meta'][1:] = sorted(exts['.meta'][1:], key=(lambda info: info['ctype_timestamp']), reverse=True)
            if (exts['.meta'][1]['ctype_timestamp'] > exts['.meta'][0]['ctype_timestamp']):
                if (exts['.meta'][1]['timestamp'] == exts['.meta'][0]['timestamp']):
                    exts['.meta'][:2] = [exts['.meta'][1], exts['.meta'][0]]
                    retain = 1
                else:
                    retain = 2
        results.setdefault('obsolete', []).extend(exts['.meta'][retain:])
        exts['.meta'] = exts['.meta'][:retain]
    self._process_ondisk_files(exts, results, **kwargs)
    if ('data_info' in results):
        if exts.get('.meta'):
            results['meta_info'] = exts['.meta'][0]
            ctype_info = exts['.meta'].pop()
            if (ctype_info['ctype_timestamp'] > results['data_info']['timestamp']):
                results['ctype_info'] = ctype_info
    elif exts.get('.ts'):
        results['ts_info'] = exts['.ts'][0]
    for info_key in ('data_info', 'meta_info', 'ts_info', 'ctype_info'):
        info = results.get(info_key)
        key = (info_key[:(-5)] + '_file')
        results[key] = (join(datadir, info['filename']) if info else None)
    if verify:
        assert self._verify_ondisk_files(results, **kwargs), ('On-disk    file    search    algorithm    contract    is    broken:    %s' % str(results))
    return results
