@publisher('previs')
def check_unique_shot_names():
    shot_nodes = pm.ls(type='shot')

    shot_names = []
    shots_with_non_unique_shot_names = []
    for shot in shot_nodes:
        shot_name = shot.shotName.get()
        if shot_name in shot_names:
            shots_with_non_unique_shot_names.append(shot)
        else:
            shot_names.append(shot_name)

    if len(shots_with_non_unique_shot_names) > 0:
        raise PublishError(
            'The following shots have non-unique shot names:<br>'
            '<br>'
            '%s' % (
                ', '.join(
                    map(
                        lambda x: x.shotName.get(),
                        shots_with_non_unique_shot_names
                    )
                )
            )
        )
check if the shot names are unique
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/publish.py/check_unique_shot_names