MCPcopy Create free account
hub / github.com/chubin/cheat.sh / __select_random_topic

Method __select_random_topic

lib/routing.py:129–140  ·  view source on GitHub ↗
(prefix, topic_list)

Source from the content-addressed store, hash-verified

127 """
128
129 def __select_random_topic(prefix, topic_list):
130 # Here we remove the special cases
131 cleaned_topic_list = [
132 x for x in topic_list if "/" not in x and ":" not in x
133 ]
134
135 # Here we still check that cleaned_topic_list in not empty
136 if not cleaned_topic_list:
137 return prefix
138
139 random_topic = random.choice(cleaned_topic_list)
140 return prefix + random_topic
141
142 if topic.endswith("/:random") or topic.lstrip("/") == ":random":
143 # We strip the :random part and see if the query is valid by running a get_topics_list()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected