code: def rebuild(self, year, month):
      # Every mask is 7 days longer to handle cross-year weekly periods.
      rr = self.rrule
      if year != self.lastyear:
          self.yearlen = 365 + calendar.isleap(year)
          self.nextyearlen = 365 + calendar.isleap(year + 1)
          firstyday = datetime.date(year, 1, 1)
          self.yearordinal = firstyday.toordinal()
          self.yearweekday = firstyday.weekday()
  
          wday = datetime.date(year, 1, 1).weekday()
          if self.yearlen == 365:
              self.mmask = M365MASK
              self.mdaymask = MDAY365MASK
              self.nmdaymask = NMDAY365MASK
              self.wdaymask = WDAYMASK[wday:]
              self.mrange = M365RANGE
          else:
              self.mmask = M366MASK
              self.mdaymask = MDAY366MASK
              self.nmdaymask = NMDAY366MASK
              self.wdaymask = WDAYMASK[wday:]
              self.mrange = M366RANGE
  
          if not rr._byweekno:
              self.wnomask = None
          else:
              self.wnomask = [0] * (self.yearlen + 7)
              # no1wkst = firstwkst = self.wdaymask.index(rr._wkst)
              no1wkst = firstwkst = (
                  7 - self.yearweekday + rr._wkst
              ) % 7
              if no1wkst >= 4:
                  no1wkst = 0
                  # Number of days in the year, plus the days we got
                  # from last year.
                  wyearlen = (
                      self.yearlen + (self.yearweekday - rr._wkst) % 7
                  )
              else:
                  # Number of days in the year, minus the days we
                  # left in last year.
                  wyearlen = self.yearlen - no1wkst
              div, mod = divmod(wyearlen, 7)
              numweeks = div + mod // 4
              for n in rr._byweekno:
                  if n < 0:
                      n += numweeks + 1
                  if not (0 < n <= numweeks):
                      continue
                  if n > 1:
                      i = no1wkst + (n - 1) * 7
                      if no1wkst != firstwkst:
                          i -= 7 - firstwkst
                  else:
                      i = no1wkst
                  for j in range(7):
                      self.wnomask[i] = 1
                      i += 1
                      if self.wdaymask[i] == rr._wkst:
                          break
              if 1 in rr._byweekno:
                  # Check week number 1 of next year as well
                  # TODO: Check -numweeks for next year.
                  i = no1wkst + numweeks * 7
                  if no1wkst != firstwkst:
                      i -= 7 - firstwkst
                  if i < self.yearlen:
                      # If week starts in next year, we
                      # don't care about it.
                      for j in range(7):
                          self.wnomask[i] = 1
                          i += 1
                          if self.wdaymask[i] == rr._wkst:
                              break
              if no1wkst:
                  # Check last week number of last year as
                  # well. If no1wkst is 0, either the year
                  # started on week start, or week number 1
                  # got days from last year, so there are no
                  # days from last year's last week number in
                  # this year.
                  if -1 not in rr._byweekno:
                      lyearweekday = datetime.date(
                          year - 1, 1, 1
                      ).weekday()
                      lno1wkst = (7 - lyearweekday + rr._wkst) % 7
                      lyearlen = 365 + calendar.isleap(year - 1)
                      if lno1wkst >= 4:
                          lno1wkst = 0
                          lnumweeks = (
                              52
                              + (
                                  lyearlen
                                  + (lyearweekday - rr._wkst) % 7
                              )
                              % 7
                              // 4
                          )
                      else:
                          lnumweeks = (
                              52 + (self.yearlen - no1wkst) % 7 // 4
                          )
                  else:
                      lnumweeks = -1
                  if lnumweeks in rr._byweekno:
                      for i in range(no1wkst):
                          self.wnomask[i] = 1
  
      if rr._bynweekday and (
          month != self.lastmonth or year != self.lastyear
      ):
          ranges = []
          if rr._freq == YEARLY:
              if rr._bymonth:
                  for month in rr._bymonth:
                      ranges.append(self.mrange[month - 1 : month + 1])
              else:
                  ranges = [(0, self.yearlen)]
          elif rr._freq == MONTHLY:
              ranges = [self.mrange[month - 1 : month + 1]]
          if ranges:
              # Weekly frequency won't get here, so we may not
              # care about cross-year weekly periods.
              self.nwdaymask = [0] * self.yearlen
              for first, last in ranges:
                  last -= 1
                  for wday, n in rr._bynweekday:
                      if n < 0:
                          i = last + (n + 1) * 7
                          i -= (self.wdaymask[i] - wday) % 7
                      else:
                          i = first + (n - 1) * 7
                          i += (7 - self.wdaymask[i] + wday) % 7
                      if first <= i <= last:
                          self.nwdaymask[i] = 1
  
      if rr._byeaster:
          self.eastermask = [0] * (self.yearlen + 7)
          eyday = easter.easter(year).toordinal() - self.yearordinal
          for offset in rr._byeaster:
              self.eastermask[eyday + offset] = 1
  
      self.lastyear = year
      self.lastmonth = month
  
imports: import calendar
  import datetime
  import heapq
  import itertools
  import re
  import sys
  from functools import wraps
  from warnings import warn
  from six import advance_iterator, integer_types
  from six.moves import _thread, range
  from ._common import weekday
label_desc: Use image node_id 2 for calling the _iterinfo obj's underlying member method code with example usage: obj.rebuild(year, month) without return types