def suggest_merge_label(self, *data): """ Determine what merge label to suggest given datasets """ # Find longest common prefix for data suggestion = common_prefix([d.label for d in data]) if len(suggestion) < 3: suggestion = 'Merged data' # Now check if the suggestion already exists, and if so add a suffix labels = self.labels if suggestion in labels: suffix = 2 while "{0} [{1}]".format(suggestion, suffix) in labels: suffix += 1 suggestion = "{0} [{1}]".format(suggestion, suffix) return suggestion