#NEWLINE# def get_user_from_topic( s ) : #NEWLINE# #INDENT# "Extracts the username from a topic or Stream object.\n\n  Topics look like: 'stream/bar@example.com/comments'\n\n  Returns:\n    A string, the username, or None if the topic name didn't appear to contain a\n    valid userid.\n  " #NEWLINE# o = None #NEWLINE# if ( not ( isinstance ( s , str ) or isinstance ( s , unicode ) ) ) : #NEWLINE# #INDENT# s = s . key ( ) . name ( ) #NEWLINE# #UNINDENT# list = s . split ( '/' ) #NEWLINE# try : #NEWLINE# #INDENT# email = list [ 1 ] #NEWLINE# if ( '@' in email ) : #NEWLINE# #INDENT# o = email #NEWLINE# #UNINDENT# #UNINDENT# except IndexError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return o