nodes: 0, module; 1, function_definition; 2, function_name:import_blacklist; 3, parameters; 4, block; 5, identifier:self; 6, identifier:parser; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, comment:"""Import blacklist.
  
          New entries parsed by 'parser' will be added to the blacklist.
  
          :param parser: sorting hat parser
          """; 14, assignment; 15, call; 16, assignment; 17, identifier:entry; 18, identifier:blacklist; 19, block; 20, call; 21, identifier:blacklist; 22, attribute; 23, attribute; 24, argument_list; 25, identifier:n; 26, integer:0; 27, try_statement; 28, attribute; 29, argument_list; 30, identifier:parser; 31, identifier:blacklist; 32, identifier:self; 33, identifier:log; 34, string:"Loading blacklist..."; 35, block; 36, except_clause; 37, except_clause; 38, identifier:self; 39, identifier:log; 40, binary_operator:"%d/%d blacklist entries loaded" % (n, len(blacklist)); 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, as_pattern; 45, block; 46, as_pattern; 47, block; 48, string:"%d/%d blacklist entries loaded"; 49, tuple; 50, call; 51, call; 52, augmented_assignment; 53, identifier:ValueError; 54, as_pattern_target; 55, raise_statement; 56, identifier:AlreadyExistsError; 57, as_pattern_target; 58, expression_statement; 59, expression_statement; 60, identifier:n; 61, call; 62, attribute; 63, argument_list; 64, attribute; 65, argument_list; 66, identifier:n; 67, integer:1; 68, identifier:e; 69, call; 70, identifier:e; 71, assignment; 72, call; 73, identifier:len; 74, argument_list; 75, identifier:api; 76, identifier:add_to_matching_blacklist; 77, attribute; 78, attribute; 79, identifier:self; 80, identifier:display; 81, string; 82, keyword_argument; 83, identifier:RuntimeError; 84, argument_list; 85, identifier:msg; 86, binary_operator:"%s. Not added." % str(e); 87, attribute; 88, argument_list; 89, identifier:blacklist; 90, identifier:self; 91, identifier:db; 92, identifier:entry; 93, identifier:excluded; 94, string_content:load_blacklist.tmpl; 95, identifier:entry; 96, attribute; 97, call; 98, string:"%s. Not added."; 99, call; 100, identifier:self; 101, identifier:warning; 102, identifier:msg; 103, identifier:entry; 104, identifier:excluded; 105, identifier:str; 106, argument_list; 107, identifier:str; 108, argument_list; 109, identifier:e; 110, identifier:e
code: def import_blacklist(self, parser):
          """Import blacklist.
  
          New entries parsed by 'parser' will be added to the blacklist.
  
          :param parser: sorting hat parser
          """
          blacklist = parser.blacklist
  
          self.log("Loading blacklist...")
          n = 0
  
          for entry in blacklist:
              try:
                  api.add_to_matching_blacklist(self.db, entry.excluded)
                  self.display('load_blacklist.tmpl', entry=entry.excluded)
                  n += 1
              except ValueError as e:
                  raise RuntimeError(str(e))
              except AlreadyExistsError as e:
                  msg = "%s. Not added." % str(e)
                  self.warning(msg)
  
          self.log("%d/%d blacklist entries loaded" % (n, len(blacklist)))