parameters: (topic, filename, period)
docstring: publisher
docstring_summary: publisher
docstring_tokens: publisher
function: def topic_publisher(topic, filename, period):
      """publisher"""
      cyber.init()
      node = cyber.Node("replay_file")
      meta_msg = None
      msg = None
      if not topic:
          print("Topic not specified, start to guess")
          meta_msg, msg = g_message_manager.parse_file(filename)
          topic = meta_msg.topic()
      else:
          meta_msg = g_message_manager.get_msg_meta_by_topic(topic)
          if not meta_msg:
              print("Failed to find meta info for topic: %s" % (topic))
              return False
          msg = meta_msg.parse_file(filename)
          if not msg:
              print("Failed to parse file[%s] with topic[%s]" % (filename,
                                                                 topic))
              return False
  
      if not msg or not meta_msg:
          print("Unknown topic: %s" % topic)
          return False
  
      writer = node.create_writer(topic, meta_msg.msg_type)
  
      if period == 0:
          while not cyber.is_shutdown():
              input("Press any key to publish one message...")
              writer.write(msg)
              print("Topic[%s] message published" % topic)
      else:
          print("started to publish topic[%s] message with rate period %s" %
                (topic, period))
          while not cyber.is_shutdown():
              writer.write(msg)
              time.sleep(period)
function_tokens: def topic_publisher ( topic , filename , period ) : cyber . init ( ) node = cyber . Node ( "replay_file" ) meta_msg = None msg = None if not topic : print ( "Topic not specified, start to guess" ) meta_msg , msg = g_message_manager . parse_file ( filename ) topic = meta_msg . topic ( ) else : meta_msg = g_message_manager . get_msg_meta_by_topic ( topic ) if not meta_msg : print ( "Failed to find meta info for topic: %s" % ( topic ) ) return False msg = meta_msg . parse_file ( filename ) if not msg : print ( "Failed to parse file[%s] with topic[%s]" % ( filename , topic ) ) return False if not msg or not meta_msg : print ( "Unknown topic: %s" % topic ) return False writer = node . create_writer ( topic , meta_msg . msg_type ) if period == 0 : while not cyber . is_shutdown ( ) : input ( "Press any key to publish one message..." ) writer . write ( msg ) print ( "Topic[%s] message published" % topic ) else : print ( "started to publish topic[%s] message with rate period %s" % ( topic , period ) ) while not cyber . is_shutdown ( ) : writer . write ( msg ) time . sleep ( period )