def _create_index_file(<EOL>root_dir, location, image_files, dirs, force_no_processing=False):
<EOL>header_text ='<STR_LIT>' + location + '<STR_LIT>' + str(len(image_files)) + '<STR_LIT>'<EOL>html = [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' + str(<NUM_LIT> / IMAGES_PER_ROW) + '<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' + header_text + '<STR_LIT>'<EOL>]<EOL>directories = []<EOL>if root_dir != location:<EOL><INDENT>directories = ['<STR_LIT:..>']<EOL><DEDENT>directories += dirs<EOL>if len(directories) > <NUM_LIT:0>:<EOL><INDENT>html.append('<STR_LIT>')<EOL><DEDENT>for directory in directories:<EOL><INDENT>link = directory + '<STR_LIT:/>' + INDEX_FILE_NAME<EOL>html += [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' + link + '<STR_LIT>' + directory + '<STR_LIT>',<EOL>'<STR_LIT>'<EOL>]<EOL><DEDENT>table_row_count = <NUM_LIT:1><EOL>html += ['<STR_LIT>', '<STR_LIT>']<EOL>for image_file in image_files:<EOL><INDENT>if table_row_count == <NUM_LIT:1>:<EOL><INDENT>html.append('<STR_LIT>')<EOL><DEDENT>img_src = _get_thumbnail_src_from_file(<EOL>location, image_file, force_no_processing<EOL>)<EOL>link_target = _get_image_link_target_from_file(<EOL>location, image_file, force_no_processing<EOL>)<EOL>html += [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' + link_target + '<STR_LIT>',<EOL>'<STR_LIT>' + img_src + '<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>]<EOL>if table_row_count == IMAGES_PER_ROW:<EOL><INDENT>table_row_count = <NUM_LIT:0><EOL>html.append('<STR_LIT>')<EOL><DEDENT>table_row_count += <NUM_LIT:1><EOL><DEDENT>html += ['<STR_LIT>', '<STR_LIT>']<EOL>html += [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>]<EOL>index_file_path = _get_index_file_path(location)<EOL>print('<STR_LIT>' % index_file_path)<EOL>index_file = open(index_file_path, '<STR_LIT:w>')<EOL>index_file.write('<STR_LIT:\n>'.join(html))<EOL>index_file.close()<EOL>return index_file_path<EOL>
Create an index file in the given location, supplying known lists of
present image files and subdirectories.
@param {String} root_dir - The root directory of the entire crawl. Used to
    ascertain whether the given location is the top level.
@param {String} location - The current directory of the crawl. The index
    file will be created here.
@param {[String]} image_files - A list of image file names in the location.
    These will be displayed in the index file's gallery.
@param {[String]} dirs - The subdirectories of the location directory.
    These will be displayed as links further down the file structure.
@param {Boolean=False} force_no_processing - If True, do not attempt to
    actually process thumbnails, PIL images or anything. Simply index
    <img> tags with original file src attributes.
@return {String} The full path (location plus filename) of the newly
    created index file. Intended for usage cleaning up created files.