original_docstring:  creates calendar layout as a word table. 
docstring: creates calendar layout as a word table.
docstring_tokens: creates calendar layout as a word table .
code: def add_dates_to_table(start_of_month,table,num_days):
  
      ''' creates calendar layout as a word table. ''' 
      
      def add_date_to_cell(table,row,column,counter_days):
          cell = table.cell(row,column)
          cell_grey_bg = parse_xml(r'<w:shd {} w:fill="f7f7f7"/>'.format(nsdecls('w')))
          cell._tc.get_or_add_tcPr().append(cell_grey_bg)
          p = cell.paragraphs[0]
          p_properties = p.add_run(str(counter_days))
          p_properties.bold =  True
          p_properties.font.size = Pt(CAL_FONT_SIZE)
          p.alignment = WD_ALIGN_PARAGRAPH.RIGHT
          counter_days += 1
          return counter_days
  
      header_cells = table.rows[0].cells
      days_list = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
      for day in range(7):
          header_cells[day].text = days_list[day]
  
      # month starts on a sunday
      if start_of_month == 0:
          counter_days = 1
          for row in range(1,14,2):
              for column in range(7):
                  if counter_days == num_days:
                      break
                  counter_days = add_date_to_cell(table,row,column,counter_days)
      
      # month starts on a saturday
      elif start_of_month == 6:
          counter_days = 1
          for row in range(1,16,2):
              if row == 1:
                  counter_days = add_date_to_cell(table,row,6,counter_days)
              else:
                  for column in range(7):
                      if counter_days == num_days:
                          break
                      counter_days = add_date_to_cell(table,row,column,counter_days)
  
  
      # month starts on a week day
      elif start_of_month in [1,2,3,4,5]:
          counter_days = 1
          for row in range(1,14,2):
              if counter_days == num_days:
                  break
              if row == 1:
                  for column in range(start_of_month,7):
                      counter_days = add_date_to_cell(table,row,column,counter_days)
              else:
                  for column in range(7):
                      if counter_days == num_days:
                          break
                      counter_days = add_date_to_cell(table,row,column,counter_days)
code_tokens: def add_dates_to_table ( start_of_month , table , num_days ) : def add_date_to_cell ( table , row , column , counter_days ) : cell = table . cell ( row , column ) cell_grey_bg = parse_xml ( r'<w:shd {} w:fill="f7f7f7"/>' . format ( nsdecls ( 'w' ) ) ) cell . _tc . get_or_add_tcPr ( ) . append ( cell_grey_bg ) p = cell . paragraphs [ 0 ] p_properties = p . add_run ( str ( counter_days ) ) p_properties . bold = True p_properties . font . size = Pt ( CAL_FONT_SIZE ) p . alignment = WD_ALIGN_PARAGRAPH . RIGHT counter_days += 1 return counter_days header_cells = table . rows [ 0 ] . cells days_list = [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] for day in range ( 7 ) : header_cells [ day ] . text = days_list [ day ] if start_of_month == 0 : counter_days = 1 for row in range ( 1 , 14 , 2 ) : for column in range ( 7 ) : if counter_days == num_days : break counter_days = add_date_to_cell ( table , row , column , counter_days ) elif start_of_month == 6 : counter_days = 1 for row in range ( 1 , 16 , 2 ) : if row == 1 : counter_days = add_date_to_cell ( table , row , 6 , counter_days ) else : for column in range ( 7 ) : if counter_days == num_days : break counter_days = add_date_to_cell ( table , row , column , counter_days ) elif start_of_month in [ 1 , 2 , 3 , 4 , 5 ] : counter_days = 1 for row in range ( 1 , 14 , 2 ) : if counter_days == num_days : break if row == 1 : for column in range ( start_of_month , 7 ) : counter_days = add_date_to_cell ( table , row , column , counter_days ) else : for column in range ( 7 ) : if counter_days == num_days : break counter_days = add_date_to_cell ( table , row , column , counter_days )
short_docstring: creates calendar layout as a word table.
short_docstring_tokens: creates calendar layout as a word table .
comment: ''' creates calendar layout as a word table. '''$SEP$# month starts on a sunday$SEP$# month starts on a saturday$SEP$# month starts on a week day