Parses the DOM and returns user attributes in the sidebar.

    :type user_page: :class:`bs4.BeautifulSoup`
    :param user_page: MAL user page's DOM

    :rtype: dict
    :return: User attributes

    :raises: :class:`.InvalidUserError`, :class:`.MalformedUserPageError`

def parse_sidebar(self, user_page):
    """Parses the DOM and returns user attributes in the sidebar.

    :type user_page: :class:`bs4.BeautifulSoup`
    :param user_page: MAL user page's DOM

    :rtype: dict
    :return: User attributes

    :raises: :class:`.InvalidUserError`, :class:`.MalformedUserPageError`
    """
    user_info = {}
    # if MAL says the series doesn't exist, raise an InvalidUserError.
    error_tag = user_page.find(u'div', {u'class': u'badresult'})
    if error_tag:
        raise InvalidUserError(self.username)

    try:
      username_tag = user_page.find(u'div', {u'id': u'contentWrapper'}).find(u'h1')
      if not username_tag.find(u'div'):
        # otherwise, raise a MalformedUserPageError.
        raise MalformedUserPageError(self.username, user_page, message=u"Could not find title div")
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    info_panel_first = user_page.find(u'div', {u'id': u'content'}).find(u'table').find(u'td')

    try:
      picture_tag = info_panel_first.find(u'img')
      user_info[u'picture'] = picture_tag.get(u'src').decode('utf-8')
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    try:
      # the user ID is always present in the blogfeed link.
      all_comments_link = info_panel_first.find(u'a', text=u'Blog Feed')
      user_info[u'id'] = int(all_comments_link.get(u'href').split(u'&id=')[1])
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    infobar_headers = info_panel_first.find_all(u'div', {u'class': u'normal_header'})
    if infobar_headers:
      try:
        favorite_anime_header = infobar_headers[0]
        if u'Favorite Anime' in favorite_anime_header.text:
          user_info[u'favorite_anime'] = []
          favorite_anime_table = favorite_anime_header.nextSibling.nextSibling
          if favorite_anime_table.name == u'table':
            for row in favorite_anime_table.find_all(u'tr'):
              cols = row.find_all(u'td')
              anime_link = cols[1].find(u'a')
              link_parts = anime_link.get(u'href').split(u'/')
              # of the form /anime/467/Ghost_in_the_Shell:_Stand_Alone_Complex
              user_info[u'favorite_anime'].append(self.session.anime(int(link_parts[2])).set({u'title': anime_link.text}))
      except:
        if not self.session.suppress_parse_exceptions:
          raise

      try:
        favorite_manga_header = infobar_headers[1]
        if u'Favorite Manga' in favorite_manga_header.text:
          user_info[u'favorite_manga'] = []
          favorite_manga_table = favorite_manga_header.nextSibling.nextSibling
          if favorite_manga_table.name == u'table':
            for row in favorite_manga_table.find_all(u'tr'):
              cols = row.find_all(u'td')
              manga_link = cols[1].find(u'a')
              link_parts = manga_link.get(u'href').split(u'/')
              # of the form /manga/467/Ghost_in_the_Shell:_Stand_Alone_Complex
              user_info[u'favorite_manga'].append(self.session.manga(int(link_parts[2])).set({u'title': manga_link.text}))
      except:
        if not self.session.suppress_parse_exceptions:
          raise

      try:
        favorite_character_header = infobar_headers[2]
        if u'Favorite Characters' in favorite_character_header.text:
          user_info[u'favorite_characters'] = {}
          favorite_character_table = favorite_character_header.nextSibling.nextSibling
          if favorite_character_table.name == u'table':
            for row in favorite_character_table.find_all(u'tr'):
              cols = row.find_all(u'td')
              character_link = cols[1].find(u'a')
              link_parts = character_link.get(u'href').split(u'/')
              # of the form /character/467/Ghost_in_the_Shell:_Stand_Alone_Complex
              character = self.session.character(int(link_parts[2])).set({u'title': character_link.text})

              media_link = cols[1].find(u'div').find(u'a')
              link_parts = media_link.get(u'href').split(u'/')
              # of the form /anime|manga/467
              anime = getattr(self.session, link_parts[1])(int(link_parts[2])).set({u'title': media_link.text})

              user_info[u'favorite_characters'][character] = anime
      except:
        if not self.session.suppress_parse_exceptions:
          raise

      try:
        favorite_people_header = infobar_headers[3]
        if u'Favorite People' in favorite_people_header.text:
          user_info[u'favorite_people'] = []
          favorite_person_table = favorite_people_header.nextSibling.nextSibling
          if favorite_person_table.name == u'table':
            for row in favorite_person_table.find_all(u'tr'):
              cols = row.find_all(u'td')
              person_link = cols[1].find(u'a')
              link_parts = person_link.get(u'href').split(u'/')
              # of the form /person/467/Ghost_in_the_Shell:_Stand_Alone_Complex
              user_info[u'favorite_people'].append(self.session.person(int(link_parts[2])).set({u'title': person_link.text}))
      except:
        if not self.session.suppress_parse_exceptions:
          raise
    return user_info