def _scan_file(filename, sentinel, source_type='import'):
    '''Generator that performs the actual scanning of files.

    Yeilds a tuple containing import type, import path, and an extra file
    that should be scanned. Extra file scans should be the file or directory
    that relates to the import name.
    '''
    filename = os.path.abspath(filename)
    real_filename = os.path.realpath(filename)

    if os.path.getsize(filename) <= max_file_size:
        if real_filename not in sentinel and os.path.isfile(filename):
            sentinel.add(real_filename)

            basename = os.path.basename(filename)
            scope, imports = ast_scan_file(filename)

            if scope is not None and imports is not None:
                for imp in imports:
                    yield (source_type, imp.module, None)

                if 'INSTALLED_APPS' in scope and basename == 'settings.py':
                    log.info('Found Django settings: %s', filename)
                    for item in django.handle_django_settings(filename):
                        yield item
            else:
                log.warn('Could not scan imports from: %s', filename)
    else:
        log.warn('File size too large: %s', filename)
Generator that performs the actual scanning of files.

    Yeilds a tuple containing import type, import path, and an extra file
    that should be scanned. Extra file scans should be the file or directory
    that relates to the import name.