nodes: 0, module; 1, function_definition; 2, function_name:add_identities; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:db; 7, identifier:identities; 8, identifier:backend; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, comment:""" Load identities list from backend in Sorting Hat """; 15, call; 16, assignment; 17, identifier:identity; 18, identifier:identities; 19, block; 20, call; 21, attribute; 22, argument_list; 23, identifier:total; 24, integer:0; 25, try_statement; 26, attribute; 27, argument_list; 28, identifier:logger; 29, identifier:info; 30, string:"Adding the identities to SortingHat"; 31, block; 32, except_clause; 33, identifier:logger; 34, identifier:info; 35, string:"Total identities added to SH: %i"; 36, identifier:total; 37, expression_statement; 38, expression_statement; 39, as_pattern; 40, block; 41, call; 42, augmented_assignment; 43, identifier:Exception; 44, as_pattern_target; 45, expression_statement; 46, continue_statement; 47, attribute; 48, argument_list; 49, identifier:total; 50, integer:1; 51, identifier:e; 52, call; 53, identifier:cls; 54, identifier:add_identity; 55, identifier:db; 56, identifier:identity; 57, identifier:backend; 58, attribute; 59, argument_list; 60, identifier:logger; 61, identifier:error; 62, binary_operator:"Unexcepted error when adding identities: %s" % e; 63, string:"Unexcepted error when adding identities: %s"; 64, identifier:e
code: def add_identities(cls, db, identities, backend):
          """ Load identities list from backend in Sorting Hat """
  
          logger.info("Adding the identities to SortingHat")
  
          total = 0
  
          for identity in identities:
              try:
                  cls.add_identity(db, identity, backend)
                  total += 1
              except Exception as e:
                  logger.error("Unexcepted error when adding identities: %s" % e)
                  continue
  
          logger.info("Total identities added to SH: %i", total)