nodes: 0, module; 1, function_definition; 2, function_name:import_organizations; 3, parameters; 4, block; 5, identifier:self; 6, identifier:parser; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, identifier:overwrite; 12, False; 13, comment:"""Import organizations.
  
          New domains and organizations parsed by 'parser' will be added
          to the registry. Remember that a domain can only be assigned to
          one organization. If one of the given domains is already on the registry,
          the new relationship will NOT be created unless 'overwrite' were set
          to 'True'.
  
          :param parser: sorting hat parser
          :param overwrite: force to reassign domains
          """; 14, assignment; 15, identifier:org; 16, identifier:orgs; 17, block; 18, identifier:orgs; 19, attribute; 20, try_statement; 21, for_statement; 22, identifier:parser; 23, identifier:organizations; 24, block; 25, except_clause; 26, except_clause; 27, identifier:dom; 28, attribute; 29, block; 30, expression_statement; 31, as_pattern; 32, block; 33, as_pattern; 34, block; 35, identifier:org; 36, identifier:domains; 37, try_statement; 38, call; 39, identifier:ValueError; 40, as_pattern_target; 41, raise_statement; 42, identifier:AlreadyExistsError; 43, as_pattern_target; 44, pass_statement; 45, block; 46, except_clause; 47, except_clause; 48, attribute; 49, argument_list; 50, identifier:e; 51, call; 52, identifier:e; 53, expression_statement; 54, expression_statement; 55, as_pattern; 56, block; 57, as_pattern; 58, block; 59, identifier:api; 60, identifier:add_organization; 61, attribute; 62, attribute; 63, identifier:RuntimeError; 64, argument_list; 65, call; 66, call; 67, tuple; 68, as_pattern_target; 69, raise_statement; 70, identifier:AlreadyExistsError; 71, as_pattern_target; 72, expression_statement; 73, expression_statement; 74, identifier:self; 75, identifier:db; 76, identifier:org; 77, identifier:name; 78, call; 79, attribute; 80, argument_list; 81, attribute; 82, argument_list; 83, identifier:ValueError; 84, identifier:NotFoundError; 85, identifier:e; 86, call; 87, identifier:e; 88, assignment; 89, call; 90, identifier:str; 91, argument_list; 92, identifier:api; 93, identifier:add_domain; 94, attribute; 95, attribute; 96, attribute; 97, keyword_argument; 98, keyword_argument; 99, identifier:self; 100, identifier:display; 101, string; 102, keyword_argument; 103, keyword_argument; 104, identifier:RuntimeError; 105, argument_list; 106, identifier:msg; 107, binary_operator:"%s. Not updated." % str(e); 108, attribute; 109, argument_list; 110, identifier:e; 111, identifier:self; 112, identifier:db; 113, identifier:org; 114, identifier:name; 115, identifier:dom; 116, identifier:domain; 117, identifier:is_top_domain; 118, attribute; 119, identifier:overwrite; 120, identifier:overwrite; 121, string_content:load_domains.tmpl; 122, identifier:domain; 123, attribute; 124, identifier:organization; 125, attribute; 126, call; 127, string:"%s. Not updated."; 128, call; 129, identifier:self; 130, identifier:warning; 131, identifier:msg; 132, identifier:dom; 133, identifier:is_top_domain; 134, identifier:dom; 135, identifier:domain; 136, identifier:org; 137, identifier:name; 138, identifier:str; 139, argument_list; 140, identifier:str; 141, argument_list; 142, identifier:e; 143, identifier:e
code: def import_organizations(self, parser, overwrite=False):
          """Import organizations.
  
          New domains and organizations parsed by 'parser' will be added
          to the registry. Remember that a domain can only be assigned to
          one organization. If one of the given domains is already on the registry,
          the new relationship will NOT be created unless 'overwrite' were set
          to 'True'.
  
          :param parser: sorting hat parser
          :param overwrite: force to reassign domains
          """
          orgs = parser.organizations
  
          for org in orgs:
              try:
                  api.add_organization(self.db, org.name)
              except ValueError as e:
                  raise RuntimeError(str(e))
              except AlreadyExistsError as e:
                  pass
  
              for dom in org.domains:
                  try:
                      api.add_domain(self.db, org.name, dom.domain,
                                     is_top_domain=dom.is_top_domain,
                                     overwrite=overwrite)
                      self.display('load_domains.tmpl', domain=dom.domain,
                                   organization=org.name)
                  except (ValueError, NotFoundError) as e:
                      raise RuntimeError(str(e))
                  except AlreadyExistsError as e:
                      msg = "%s. Not updated." % str(e)
                      self.warning(msg)