def CreateMD5(source_filename, target_filename=None):
if target_filename is None:<EOL><INDENT>target_filename = source_filename + '<STR_LIT>'<EOL><DEDENT>from six.moves.urllib.parse import urlparse<EOL>source_url = urlparse(source_filename)<EOL>if _UrlIsLocal(source_url):<EOL><INDENT>md5_contents = Md5Hex(filename=source_filename)<EOL><DEDENT>else:<EOL><INDENT>md5_contents = Md5Hex(contents=GetFileContents(source_filename, binary=True))<EOL><DEDENT>CreateFile(target_filename, md5_contents)<EOL>
Creates a md5 file from a source file (contents are the md5 hash of source file)

:param unicode source_filename:
    Path to source file

:type target_filename: unicode or None
:param target_filename:
    Name of the target file with the md5 contents

    If None, defaults to source_filename + '.md5'