parameters: (topic)
return_statement: return buff.getvalue()
docstring: Get human-readable topic description
      
      :param topic: topic name, ``str``
docstring_summary: Get human-readable topic description
      
      :param topic: topic name, ``str``
docstring_tokens: Get human - readable topic description : param topic : topic name str
function: def get_info_text(topic):
      """
      Get human-readable topic description
      
      :param topic: topic name, ``str``
      """
      try:
          from cStringIO import StringIO
      except ImportError:
          from io import StringIO
      import itertools
      buff = StringIO()
      def topic_type(t, topic_types):
          matches = [t_type for t_name, t_type in topic_types if t_name == t]
          if matches:
              return matches[0]
          return 'unknown type'
  
      master = rosgraph.Master('/rostopic')
      try:
          state = master.getSystemState()
  
          pubs, subs, _ = state
          # filter based on topic
          subs = [x for x in subs if x[0] == topic]
          pubs = [x for x in pubs if x[0] == topic]
  
          topic_types = _master_get_topic_types(master)
              
      except socket.error:
          raise ROSTopicIOException("Unable to communicate with master!")
  
      if not pubs and not subs:
          raise ROSTopicException("Unknown topic %s"%topic)
  
      buff.write("Type: %s\n\n"%topic_type(topic, topic_types))
  
      if pubs:
          buff.write("Publishers: \n")
          for p in itertools.chain(*[l for x, l in pubs]):
              buff.write(" * %s (%s)\n"%(p, get_api(master, p)))
      else:
          buff.write("Publishers: None\n")
      buff.write('\n')
  
      if subs:
          buff.write("Subscribers: \n")
          for p in itertools.chain(*[l for x, l in subs]):
              buff.write(" * %s (%s)\n"%(p, get_api(master, p)))
      else:
          buff.write("Subscribers: None\n")
      buff.write('\n')
      return buff.getvalue()
function_tokens: def get_info_text ( topic ) : try : from cStringIO import StringIO except ImportError : from io import StringIO import itertools buff = StringIO ( ) def topic_type ( t , topic_types ) : matches = [ t_type for t_name , t_type in topic_types if t_name == t ] if matches : return matches [ 0 ] return 'unknown type' master = rosgraph . Master ( '/rostopic' ) try : state = master . getSystemState ( ) pubs , subs , _ = state # filter based on topic subs = [ x for x in subs if x [ 0 ] == topic ] pubs = [ x for x in pubs if x [ 0 ] == topic ] topic_types = _master_get_topic_types ( master ) except socket . error : raise ROSTopicIOException ( "Unable to communicate with master!" ) if not pubs and not subs : raise ROSTopicException ( "Unknown topic %s" % topic ) buff . write ( "Type: %s\n\n" % topic_type ( topic , topic_types ) ) if pubs : buff . write ( "Publishers: \n" ) for p in itertools . chain ( * [ l for x , l in pubs ] ) : buff . write ( " * %s (%s)\n" % ( p , get_api ( master , p ) ) ) else : buff . write ( "Publishers: None\n" ) buff . write ( '\n' ) if subs : buff . write ( "Subscribers: \n" ) for p in itertools . chain ( * [ l for x , l in subs ] ) : buff . write ( " * %s (%s)\n" % ( p , get_api ( master , p ) ) ) else : buff . write ( "Subscribers: None\n" ) buff . write ( '\n' ) return buff . getvalue ( )