nodes: 0, module; 1, function_definition; 2, function_name:_set_and_filter; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, comment:"""Filters the registered updates and sort out what is not needed
  
          This method filters out the formatoptions that have not changed, sets
          the new value and returns an iterable that is sorted by the priority
          (highest priority comes first) and dependencies
  
          Returns
          -------
          list
              list of :class:`Formatoption` objects that have to be updated"""; 18, assignment; 19, assignment; 20, identifier:key; 21, attribute; 22, block; 23, pattern_list; 24, call; 25, block; 26, assignment; 27, identifier:fmto; 28, identifier:fmtos; 29, block; 30, assignment; 31, call; 32, call; 33, identifier:fmtos; 34, identifier:fmtos; 35, list; 36, identifier:seen; 37, call; 38, identifier:self; 39, identifier:_force; 40, expression_statement; 41, identifier:key; 42, identifier:value; 43, identifier:chain; 44, argument_list; 45, if_statement; 46, expression_statement; 47, expression_statement; 48, comment:# if the key is shared, a warning will be printed as long as; 49, comment:# this plotter is not also updating (for example due to a whole; 50, comment:# project update); 51, if_statement; 52, expression_statement; 53, if_statement; 54, identifier:fmtos; 55, call; 56, expression_statement; 57, attribute; 58, False; 59, attribute; 60, argument_list; 61, attribute; 62, argument_list; 63, identifier:set; 64, argument_list; 65, call; 66, call; 67, conditional_expression:six.iteritems(
                      {key: getattr(self, key).default for key in self})
                  if self._todefault else (); 68, comparison_operator:key in seen; 69, block; 70, call; 71, assignment; 72, boolean_operator; 73, block; 74, else_clause; 75, assignment; 76, identifier:changed; 77, block; 78, attribute; 79, argument_list; 80, call; 81, identifier:self; 82, identifier:_todefault; 83, attribute; 84, identifier:clear; 85, attribute; 86, identifier:clear; 87, attribute; 88, argument_list; 89, attribute; 90, argument_list; 91, call; 92, attribute; 93, tuple; 94, identifier:key; 95, identifier:seen; 96, continue_statement; 97, attribute; 98, argument_list; 99, identifier:fmto; 100, call; 101, comparison_operator:key in self._shared; 102, comparison_operator:key not in self._force; 103, if_statement; 104, expression_statement; 105, block; 106, identifier:changed; 107, boolean_operator; 108, expression_statement; 109, identifier:self; 110, identifier:_insert_additionals; 111, identifier:fmtos; 112, identifier:seen; 113, attribute; 114, argument_list; 115, identifier:self; 116, identifier:_registered_updates; 117, identifier:self; 118, identifier:_force; 119, attribute; 120, identifier:setdefault; 121, identifier:key; 122, attribute; 123, identifier:six; 124, identifier:iteritems; 125, attribute; 126, attribute; 127, argument_list; 128, identifier:self; 129, identifier:_todefault; 130, identifier:seen; 131, identifier:add; 132, identifier:key; 133, identifier:getattr; 134, argument_list; 135, identifier:key; 136, attribute; 137, identifier:key; 138, attribute; 139, not_operator; 140, block; 141, assignment; 142, try_statement; 143, identifier:changed; 144, comparison_operator:key in self._force; 145, call; 146, attribute; 147, identifier:acquire; 148, identifier:self; 149, identifier:_registered_updates; 150, call; 151, identifier:value; 152, identifier:self; 153, identifier:_registered_updates; 154, identifier:six; 155, identifier:iteritems; 156, dictionary_comprehension; 157, identifier:self; 158, identifier:key; 159, identifier:self; 160, identifier:_shared; 161, identifier:self; 162, identifier:_force; 163, attribute; 164, expression_statement; 165, identifier:changed; 166, False; 167, block; 168, except_clause; 169, identifier:key; 170, attribute; 171, attribute; 172, argument_list; 173, identifier:fmto; 174, identifier:lock; 175, identifier:getattr; 176, argument_list; 177, pair; 178, for_in_clause; 179, attribute; 180, identifier:_updating; 181, call; 182, expression_statement; 183, as_pattern; 184, block; 185, identifier:self; 186, identifier:_force; 187, identifier:fmtos; 188, identifier:append; 189, identifier:fmto; 190, identifier:self; 191, identifier:key; 192, identifier:key; 193, attribute; 194, identifier:key; 195, identifier:self; 196, subscript; 197, identifier:plotter; 198, identifier:warn; 199, argument_list; 200, assignment; 201, identifier:Exception; 202, as_pattern_target; 203, expression_statement; 204, expression_statement; 205, raise_statement; 206, call; 207, identifier:default; 208, attribute; 209, identifier:key; 210, binary_operator:("%s formatoption is shared with another plotter."
                            " Use the unshare method to enable the updating") % (
                                fmto.key); 211, keyword_argument; 212, identifier:changed; 213, call; 214, identifier:e; 215, call; 216, call; 217, identifier:e; 218, identifier:getattr; 219, argument_list; 220, identifier:self; 221, identifier:_shared; 222, parenthesized_expression; 223, parenthesized_expression; 224, identifier:logger; 225, attribute; 226, attribute; 227, argument_list; 228, attribute; 229, argument_list; 230, attribute; 231, argument_list; 232, identifier:self; 233, identifier:key; 234, concatenated_string; 235, attribute; 236, identifier:self; 237, identifier:logger; 238, identifier:fmto; 239, identifier:check_and_set; 240, identifier:value; 241, keyword_argument; 242, keyword_argument; 243, attribute; 244, identifier:pop; 245, identifier:key; 246, None; 247, attribute; 248, identifier:debug; 249, string; 250, identifier:key; 251, string:"%s formatoption is shared with another plotter."; 252, string:" Use the unshare method to enable the updating"; 253, identifier:fmto; 254, identifier:key; 255, identifier:todefault; 256, attribute; 257, identifier:validate; 258, not_operator; 259, identifier:self; 260, identifier:_registered_updates; 261, identifier:self; 262, identifier:logger; 263, string_content:Failed to set %s; 264, identifier:self; 265, identifier:_todefault; 266, attribute; 267, identifier:self; 268, identifier:no_validation
code: def _set_and_filter(self):
          """Filters the registered updates and sort out what is not needed
  
          This method filters out the formatoptions that have not changed, sets
          the new value and returns an iterable that is sorted by the priority
          (highest priority comes first) and dependencies
  
          Returns
          -------
          list
              list of :class:`Formatoption` objects that have to be updated"""
          fmtos = []
          seen = set()
          for key in self._force:
              self._registered_updates.setdefault(key, getattr(self, key).value)
          for key, value in chain(
                  six.iteritems(self._registered_updates),
                  six.iteritems(
                      {key: getattr(self, key).default for key in self})
                  if self._todefault else ()):
              if key in seen:
                  continue
              seen.add(key)
              fmto = getattr(self, key)
              # if the key is shared, a warning will be printed as long as
              # this plotter is not also updating (for example due to a whole
              # project update)
              if key in self._shared and key not in self._force:
                  if not self._shared[key].plotter._updating:
                      warn(("%s formatoption is shared with another plotter."
                            " Use the unshare method to enable the updating") % (
                                fmto.key),
                           logger=self.logger)
                  changed = False
              else:
                  try:
                      changed = fmto.check_and_set(
                          value, todefault=self._todefault,
                          validate=not self.no_validation)
                  except Exception as e:
                      self._registered_updates.pop(key, None)
                      self.logger.debug('Failed to set %s', key)
                      raise e
              changed = changed or key in self._force
              if changed:
                  fmtos.append(fmto)
          fmtos = self._insert_additionals(fmtos, seen)
          for fmto in fmtos:
              fmto.lock.acquire()
          self._todefault = False
          self._registered_updates.clear()
          self._force.clear()
          return fmtos