original_docstring: Extracts the menu for the current week from a Katri Antell menu page.
docstring: Extracts the menu for the current week from a Katri Antell menu page.
docstring_tokens: Extracts the menu for the current week from a Katri Antell menu page .
code: def parse_antell_menu(name, restaurant_id):
      """Extracts the menu for the current week from a Katri Antell menu page."""
      menu_url = 'http://www.antell.fi/lounaslistat/lounaslista.html?owner={0}'. \
                 format(restaurant_id)
      resp = requests.get(menu_url)
      # Check for a failed request or a redirect
      if not resp.ok or restaurant_id not in resp.url:
          return {}
  
      today = date.today()
      first_day = today - timedelta(days=today.weekday())
      last_day = first_day + timedelta(days=5)
      menu = {}
      menu_days = []
      i = 0
  
      while i < (last_day - first_day).days:
          # pylint: disable=no-member
          menu_days.append((first_day + timedelta(days=i)).isoformat())
          i += 1
  
      soup = BeautifulSoup(resp.text, 'lxml')
      days = soup.find_all(id='lunch-content-table')[0].find_all('table')
  
      def content_filter(tag):
          """Filters away empty and too short tags."""
          return tag.name == 'td' and len(tag.text) > 6
  
      for i in range(5):
          rows = days[i].find_all(content_filter)
          if len(rows) > 3:
              day = menu_days[i]
              courses = [rows[j].text.split('\r')[0].strip() for j
                         in range(1, len(rows))]
              menu[day] = courses
  
      return {'name': name, 'menu': menu}
code_tokens: def parse_antell_menu ( name , restaurant_id ) : menu_url = 'http://www.antell.fi/lounaslistat/lounaslista.html?owner={0}' . format ( restaurant_id ) resp = requests . get ( menu_url ) if not resp . ok or restaurant_id not in resp . url : return { } today = date . today ( ) first_day = today - timedelta ( days = today . weekday ( ) ) last_day = first_day + timedelta ( days = 5 ) menu = { } menu_days = [ ] i = 0 while i < ( last_day - first_day ) . days : menu_days . append ( ( first_day + timedelta ( days = i ) ) . isoformat ( ) ) i += 1 soup = BeautifulSoup ( resp . text , 'lxml' ) days = soup . find_all ( id = 'lunch-content-table' ) [ 0 ] . find_all ( 'table' ) def content_filter ( tag ) : """Filters away empty and too short tags.""" return tag . name == 'td' and len ( tag . text ) > 6 for i in range ( 5 ) : rows = days [ i ] . find_all ( content_filter ) if len ( rows ) > 3 : day = menu_days [ i ] courses = [ rows [ j ] . text . split ( '\r' ) [ 0 ] . strip ( ) for j in range ( 1 , len ( rows ) ) ] menu [ day ] = courses return { 'name' : name , 'menu' : menu }
short_docstring: Extracts the menu for the current week from a Katri Antell menu page.
short_docstring_tokens: Extracts the menu for the current week from a Katri Antell menu page .
comment: """Extracts the menu for the current week from a Katri Antell menu page."""$SEP$# Check for a failed request or a redirect$SEP$# pylint: disable=no-member$SEP$"""Filters away empty and too short tags."""