def text_to_segments(text):
 lines = text.replace('  ', ' \xa0').splitlines()
 if (not lines):
  return []
 segments = []
 for line in lines[:(-1)]:
  if line:
   segments.append(hangups.ChatMessageSegment(line))
  segments.append(hangups.ChatMessageSegment('\n', hangups.SegmentType.LINE_BREAK))
 if lines[(-1)]:
  segments.append(hangups.ChatMessageSegment(lines[(-1)]))
 return segments

def text_to_segments ( text ) : lines = text . replace ( '  ' , ' \xa0' ) . splitlines ( ) if ( not lines ) : return [ ] segments = [ ] for line in lines [ : ( - 1 ) ] : if line : segments . append ( hangups . ChatMessageSegment ( line ) ) segments . append ( hangups . ChatMessageSegment ( '\n' , hangups . SegmentType . LINE_BREAK ) ) if lines [ ( - 1 ) ] : segments . append ( hangups . ChatMessageSegment ( lines [ ( - 1 ) ] ) ) return segments
create list of message segments from text .