topic_group_queue.py 850 B

123456789101112131415161718192021222324252627282930
  1. class TopicGroup(object):
  2. """
  3. 生成topic,group, platform, mode等信息
  4. """
  5. def __init__(self):
  6. self.spider_list = [
  7. # ("test", "recommend", "test"),
  8. ("zhsdm", "recommend", "zhuhaoshiduomo"),
  9. ("fxs", "recommend", "fuxiaoshun"),
  10. ("zwwfsn", "recommend", "zhuwanwufusunew"),
  11. ('zjsjmn', 'recommend', 'zhujinshanjinmeinew')
  12. ]
  13. def produce(self):
  14. """
  15. 工作代码
  16. :return: list [{}, {}, {}, {}, {}]
  17. """
  18. result = [
  19. {
  20. "topic": "{}_{}_prod".format(i[0], i[1]),
  21. "group": "{}_{}_prod".format(i[0], i[1]),
  22. "mode": i[1],
  23. "platform": i[2]
  24. } for i in self.spider_list
  25. ]
  26. return result
  27. # print(TopicGroup().produce())