def _insert_resource_file(cursor, module_ident, resource):
with resource.open() as file:<EOL><INDENT>fileid, _ = _insert_file(cursor, file, resource.media_type)<EOL><DEDENT>cursor.execute("""<STR_LIT>""",<EOL>(fileid, module_ident, resource.filename,))<EOL>try:<EOL><INDENT>is_same_file = cursor.fetchone()[<NUM_LIT:0>]<EOL><DEDENT>except TypeError:  <EOL><INDENT>is_same_file = None<EOL><DEDENT>if is_same_file:<EOL><INDENT>return<EOL><DEDENT>elif is_same_file is not None:  <EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>args = (module_ident, fileid, resource.filename,)<EOL>cursor.execute("""<STR_LIT>""", args)<EOL>
Insert a resource into the modules_files table. This will
    create a new file entry or associates an existing one.