def ChangeExtension(file_name, old_str, new_str):
    """
    Change the 'extension' at the end a file or directory to a new type.
    For example, change 'foo.pp' to 'foo.Data'

    Do this by substituting the last occurance of 'old_str' in the file
    name with 'new_str'. This is required because the file name may contain
    'old_str' as a legal part of the name which is not at the end of the
    directory name.

    This assumes anything after the last '.' is the file extension.  If there
    isn't a file extention, then just return the original name.

    @return string with file name & new extension
    """

    pos = file_name.rfind(old_str)
    if pos == -1:
        # old_str not found, just return the file_name
        #
        return file_name

    return file_name[:pos] + new_str