Take a given filename and return the normalized version of it.
    Where ~/ is expanded to the full OS specific home directory and all
    relative path elements are resolved.

def normalizeFilename(filename):
    """Take a given filename and return the normalized version of it.
    Where ~/ is expanded to the full OS specific home directory and all
    relative path elements are resolved.
    """
    result = os.path.expanduser(filename)
    result = os.path.abspath(result)
    return result