def fix_ext(name, ext):
    """Add extension if it is missing"""
    if not ext[0] == '.':
        ext = '.' + ext
    if not name[-len(ext):].lower() == ext.lower():
        name = name + ext
    return name