original_docstring: Parses the menu for the current week for a ISS lunch restaurant
      from the restaurant's web page.
docstring: Parses the menu for the current week for a ISS lunch restaurant
  from the restaurant's web page.
docstring_tokens: Parses the menu for the current week for a ISS lunch restaurant from the restaurant ' s web page .
code: def parse_iss_menu(name, url):
      """Parses the menu for the current week for a ISS lunch restaurant
      from the restaurant's web page."""
      day_names = ['Maanantai', 'Tiistai', 'Keskiviikko', 'Torstai', 'Perjantai']
      pattern = re.compile(r'(\d+\.\d+)\.?')
      menu = {}
      day_menu = []
      current_date = None
  
      resp = requests.get(url)
      if not resp.ok:
          return {}
  
      soup = BeautifulSoup(resp.content, 'lxml')
      if not soup.find_all('table'):
          return {}
  
      rows = soup.find_all('table')[0].find_all('tr')
      for idx, row in enumerate(rows):
          if idx == 0:
              continue
  
          columns = row.find_all('td')
          if columns[0].text in day_names and \
             re.match(pattern, columns[1].text):
              match = re.match(pattern, columns[1].text)
              current_date = datetime.strptime('{}.{}'.format(match.group(1),
                                                              datetime.now().strftime('%Y')),
                                               '%d.%m.%Y').date().isoformat()
          else:
              if len(columns[1].text) > 5:
                  day_menu.append('{}: {}'.format(columns[0].text, columns[1].text))
              if (len(columns[0].text) <= 1 and len(columns[1].text) <= 1) or \
                 idx == (len(rows) - 1):
                  if len(day_menu) > 2:
                      menu[current_date] = day_menu
                  day_menu = []
  
      return {'name': name, 'menu': menu}
code_tokens: def parse_iss_menu ( name , url ) : day_names = [ 'Maanantai' , 'Tiistai' , 'Keskiviikko' , 'Torstai' , 'Perjantai' ] pattern = re . compile ( r'(\d+\.\d+)\.?' ) menu = { } day_menu = [ ] current_date = None resp = requests . get ( url ) if not resp . ok : return { } soup = BeautifulSoup ( resp . content , 'lxml' ) if not soup . find_all ( 'table' ) : return { } rows = soup . find_all ( 'table' ) [ 0 ] . find_all ( 'tr' ) for idx , row in enumerate ( rows ) : if idx == 0 : continue columns = row . find_all ( 'td' ) if columns [ 0 ] . text in day_names and re . match ( pattern , columns [ 1 ] . text ) : match = re . match ( pattern , columns [ 1 ] . text ) current_date = datetime . strptime ( '{}.{}' . format ( match . group ( 1 ) , datetime . now ( ) . strftime ( '%Y' ) ) , '%d.%m.%Y' ) . date ( ) . isoformat ( ) else : if len ( columns [ 1 ] . text ) > 5 : day_menu . append ( '{}: {}' . format ( columns [ 0 ] . text , columns [ 1 ] . text ) ) if ( len ( columns [ 0 ] . text ) <= 1 and len ( columns [ 1 ] . text ) <= 1 ) or idx == ( len ( rows ) - 1 ) : if len ( day_menu ) > 2 : menu [ current_date ] = day_menu day_menu = [ ] return { 'name' : name , 'menu' : menu }
short_docstring: Parses the menu for the current week for a ISS lunch restaurant
  from the restaurant's web page.
short_docstring_tokens: Parses the menu for the current week for a ISS lunch restaurant from the restaurant ' s web page .
comment: """Parses the menu for the current week for a ISS lunch restaurant
      from the restaurant's web page."""