nodes: 0, module; 1, function_definition; 2, function_name:pre_upgrade_checks; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, for_statement; 11, expression_statement; 12, expression_statement; 13, comment:"""Run upgrade pre-checks prior to applying upgrades.
  
          Pre-checks should
          in general be fast to execute. Pre-checks may the use the wait_for_user
          function, to query the user for confirmation, but should respect the
          --yes-i-know option to run unattended.
  
          All pre-checks will be executed even if one fails, however if one pre-
          check fails, the upgrade process will be stopped and the user warned.
  
          :param upgrades: List of upgrades sorted in topological order.
          """; 14, assignment; 15, identifier:check; 16, attribute; 17, block; 18, identifier:u; 19, identifier:upgrades; 20, block; 21, call; 22, call; 23, identifier:errors; 24, list; 25, identifier:self; 26, identifier:global_pre_upgrade; 27, expression_statement; 28, try_statement; 29, expression_statement; 30, try_statement; 31, attribute; 32, argument_list; 33, attribute; 34, argument_list; 35, call; 36, block; 37, except_clause; 38, call; 39, block; 40, except_clause; 41, identifier:self; 42, identifier:_teardown_log_prefix; 43, identifier:self; 44, identifier:_check_errors; 45, identifier:errors; 46, concatenated_string; 47, attribute; 48, argument_list; 49, expression_statement; 50, as_pattern; 51, block; 52, attribute; 53, argument_list; 54, expression_statement; 55, as_pattern; 56, block; 57, string:"Pre-upgrade check for %s failed with the"; 58, string:" following errors:"; 59, identifier:self; 60, identifier:_setup_log_prefix; 61, keyword_argument; 62, call; 63, identifier:RuntimeError; 64, as_pattern_target; 65, expression_statement; 66, identifier:self; 67, identifier:_setup_log_prefix; 68, keyword_argument; 69, call; 70, identifier:RuntimeError; 71, as_pattern_target; 72, expression_statement; 73, identifier:plugin_id; 74, attribute; 75, identifier:check; 76, argument_list; 77, identifier:e; 78, call; 79, identifier:plugin_id; 80, attribute; 81, attribute; 82, argument_list; 83, identifier:e; 84, call; 85, identifier:check; 86, identifier:__name__; 87, attribute; 88, argument_list; 89, identifier:u; 90, identifier:name; 91, identifier:u; 92, identifier:pre_upgrade; 93, attribute; 94, argument_list; 95, identifier:errors; 96, identifier:append; 97, tuple; 98, identifier:errors; 99, identifier:append; 100, tuple; 101, attribute; 102, attribute; 103, attribute; 104, attribute; 105, identifier:check; 106, identifier:__name__; 107, identifier:e; 108, identifier:args; 109, identifier:u; 110, identifier:name; 111, identifier:e; 112, identifier:args
code: def pre_upgrade_checks(self, upgrades):
          """Run upgrade pre-checks prior to applying upgrades.
  
          Pre-checks should
          in general be fast to execute. Pre-checks may the use the wait_for_user
          function, to query the user for confirmation, but should respect the
          --yes-i-know option to run unattended.
  
          All pre-checks will be executed even if one fails, however if one pre-
          check fails, the upgrade process will be stopped and the user warned.
  
          :param upgrades: List of upgrades sorted in topological order.
          """
          errors = []
  
          for check in self.global_pre_upgrade:
              self._setup_log_prefix(plugin_id=check.__name__)
              try:
                  check()
              except RuntimeError as e:
                  errors.append((check.__name__, e.args))
  
          for u in upgrades:
              self._setup_log_prefix(plugin_id=u.name)
              try:
                  u.pre_upgrade()
              except RuntimeError as e:
                  errors.append((u.name, e.args))
  
          self._teardown_log_prefix()
  
          self._check_errors(errors, "Pre-upgrade check for %s failed with the"
                             " following errors:")