def preprocess_topics(source_groupid, source_topics, dest_groupid, topics_dest_group):
    """Pre-process the topics in source and destination group for duplicates."""
    # Is the new consumer already subscribed to any of these topics?
    common_topics = [topic for topic in topics_dest_group if topic in source_topics]
    if common_topics:
        print(
            "Error: Consumer Group ID: {groupid} is already "
            "subscribed to following topics: {topic}.\nPlease delete this "
            "topics from new group before re-running the "
            "command.".format(
                groupid=dest_groupid,
                topic=', '.join(common_topics),
            ),
            file=sys.stderr,
        )
        sys.exit(1)
    # Let's confirm what the user intends to do.
    if topics_dest_group:
        in_str = (
            "New Consumer Group: {dest_groupid} already "
            "exists.\nTopics subscribed to by the consumer groups are listed "
            "below:\n{source_groupid}: {source_group_topics}\n"
            "{dest_groupid}: {dest_group_topics}\nDo you intend to copy into"
            "existing consumer destination-group? (y/n)".format(
                source_groupid=source_groupid,
                source_group_topics=source_topics,
                dest_groupid=dest_groupid,
                dest_group_topics=topics_dest_group,
            )
        )
        prompt_user_input(in_str)
def preprocess_topics ( source_groupid , source_topics , dest_groupid , topics_dest_group ) : common_topics = [ topic for topic in topics_dest_group if topic in source_topics ] if common_topics : print ( "Error: Consumer Group ID: {groupid} is already " "subscribed to following topics: {topic}.\nPlease delete this " "topics from new group before re-running the " "command." . format ( groupid = dest_groupid , topic = ', ' . join ( common_topics ) , ) , file = sys . stderr , ) sys . exit ( 1 ) if topics_dest_group : in_str = ( "New Consumer Group: {dest_groupid} already " "exists.\nTopics subscribed to by the consumer groups are listed " "below:\n{source_groupid}: {source_group_topics}\n" "{dest_groupid}: {dest_group_topics}\nDo you intend to copy into" "existing consumer destination-group? (y/n)" . format ( source_groupid = source_groupid , source_group_topics = source_topics , dest_groupid = dest_groupid , dest_group_topics = topics_dest_group , ) ) prompt_user_input ( in_str )
Pre-process the topics in source and destination group for duplicates.