'Return all segments.
Function segments are called, and all segments get their before/after
and ljust/rjust properties applied.
:param int line:
Line number for which segments should be obtained. Is counted from
zero (botmost line).'

def get_segments(self, side=None, line=0, segment_info=None, mode=None):

    for side in ([side] if side else [u'left', u'right']):
        parsed_segments = []
        for segment in self.segments[line][side]:
            if segment[u'display_condition'](self.pl, segment_info, mode):
                process_segment(self.pl, side, segment_info, parsed_segments, segment, mode, self.colorscheme)
        for segment in parsed_segments:
            self.pl.prefix = segment[u'name']
            try:
                width = segment[u'width']
                align = segment[u'align']
                if ((width == u'auto') and (segment[u'expand'] is None)):
                    segment[u'expand'] = expand_functions.get(align)
                    if (segment[u'expand'] is None):
                        self.pl.error(u'Align    argument    must    be    \u201cr\u201d,    \u201cl\u201d    or    \u201cc\u201d,    not    \u201c{0}\u201d', align)
                try:
                    segment[u'contents'] = ((segment[u'before'] + u((segment[u'contents'] if (segment[u'contents'] is not None) else u''))) + segment[u'after'])
                except Exception as e:
                    self.pl.exception(u'Failed    to    compute    segment    contents:    {0}', str(e))
                    segment[u'contents'] = safe_unicode(segment.get(u'contents'))
                if (segment[u'width'] and (segment[u'width'] != u'auto')):
                    if (segment[u'align'] == u'l'):
                        segment[u'contents'] = segment[u'contents'].ljust(segment[u'width'])
                    elif (segment[u'align'] == u'r'):
                        segment[u'contents'] = segment[u'contents'].rjust(segment[u'width'])
                    elif (segment[u'align'] == u'c'):
                        segment[u'contents'] = segment[u'contents'].center(segment[u'width'])
                (yield segment.copy())
            except Exception as e:
                self.pl.exception(u'Failed    to    compute    segment:    {0}', str(e))
                fallback = get_fallback_segment()
                fallback.update(side=side)
                (yield fallback)
