nodes: 0, module; 1, function_definition; 2, function_name:initialize; 3, parameters; 4, block; 5, identifier:self; 6, identifier:name; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, try_statement; 15, return_statement; 16, identifier:reuse; 17, False; 18, comment:"""Create an empty Sorting Hat registry.
  
          This method creates a new database including the schema of Sorting Hat.
          Any attempt to create a new registry over an existing instance will
          produce an error, except if reuse=True. In that case, the
          database will be reused, assuming the database schema is correct
          (it won't be created in this case).
  
          :param  name: name of the database
          :param reuse: reuse database if it already exists
          """; 19, assignment; 20, assignment; 21, assignment; 22, assignment; 23, comparison_operator:'-' in name; 24, block; 25, block; 26, except_clause; 27, except_clause; 28, except_clause; 29, identifier:CMD_SUCCESS; 30, identifier:user; 31, subscript; 32, identifier:password; 33, subscript; 34, identifier:host; 35, subscript; 36, identifier:port; 37, subscript; 38, string; 39, identifier:name; 40, expression_statement; 41, return_statement; 42, expression_statement; 43, comment:# Try to access and create schema; 44, expression_statement; 45, comment:# Load countries list; 46, expression_statement; 47, as_pattern; 48, block; 49, as_pattern; 50, block; 51, as_pattern; 52, block; 53, attribute; 54, string; 55, attribute; 56, string; 57, attribute; 58, string; 59, attribute; 60, string; 61, string_content:-; 62, call; 63, identifier:CODE_VALUE_ERROR; 64, call; 65, assignment; 66, call; 67, identifier:DatabaseExists; 68, as_pattern_target; 69, if_statement; 70, identifier:DatabaseError; 71, as_pattern_target; 72, expression_statement; 73, return_statement; 74, identifier:LoadError; 75, as_pattern_target; 76, expression_statement; 77, expression_statement; 78, return_statement; 79, identifier:self; 80, identifier:_kwargs; 81, string_content:user; 82, identifier:self; 83, identifier:_kwargs; 84, string_content:password; 85, identifier:self; 86, identifier:_kwargs; 87, string_content:host; 88, identifier:self; 89, identifier:_kwargs; 90, string_content:port; 91, attribute; 92, argument_list; 93, attribute; 94, argument_list; 95, identifier:db; 96, call; 97, attribute; 98, argument_list; 99, identifier:e; 100, not_operator; 101, block; 102, identifier:e; 103, call; 104, identifier:CODE_DATABASE_ERROR; 105, identifier:e; 106, call; 107, call; 108, identifier:CODE_LOAD_ERROR; 109, identifier:self; 110, identifier:error; 111, binary_operator:"dabase name '%s' cannot contain '-' characters" % name; 112, identifier:Database; 113, identifier:create; 114, identifier:user; 115, identifier:password; 116, identifier:name; 117, identifier:host; 118, identifier:port; 119, identifier:Database; 120, argument_list; 121, identifier:self; 122, identifier:__load_countries; 123, identifier:db; 124, identifier:reuse; 125, expression_statement; 126, return_statement; 127, attribute; 128, argument_list; 129, attribute; 130, argument_list; 131, attribute; 132, argument_list; 133, string:"dabase name '%s' cannot contain '-' characters"; 134, identifier:name; 135, identifier:user; 136, identifier:password; 137, identifier:name; 138, identifier:host; 139, identifier:port; 140, call; 141, identifier:CODE_DATABASE_EXISTS; 142, identifier:self; 143, identifier:error; 144, call; 145, identifier:Database; 146, identifier:drop; 147, identifier:user; 148, identifier:password; 149, identifier:name; 150, identifier:host; 151, identifier:port; 152, identifier:self; 153, identifier:error; 154, call; 155, attribute; 156, argument_list; 157, identifier:str; 158, argument_list; 159, identifier:str; 160, argument_list; 161, identifier:self; 162, identifier:error; 163, call; 164, identifier:e; 165, identifier:e; 166, identifier:str; 167, argument_list; 168, identifier:e
code: def initialize(self, name, reuse=False):
          """Create an empty Sorting Hat registry.
  
          This method creates a new database including the schema of Sorting Hat.
          Any attempt to create a new registry over an existing instance will
          produce an error, except if reuse=True. In that case, the
          database will be reused, assuming the database schema is correct
          (it won't be created in this case).
  
          :param  name: name of the database
          :param reuse: reuse database if it already exists
          """
          user = self._kwargs['user']
          password = self._kwargs['password']
          host = self._kwargs['host']
          port = self._kwargs['port']
  
          if '-' in name:
              self.error("dabase name '%s' cannot contain '-' characters" % name)
              return CODE_VALUE_ERROR
  
          try:
              Database.create(user, password, name, host, port)
              # Try to access and create schema
              db = Database(user, password, name, host, port)
              # Load countries list
              self.__load_countries(db)
          except DatabaseExists as e:
              if not reuse:
                  self.error(str(e))
                  return CODE_DATABASE_EXISTS
          except DatabaseError as e:
              self.error(str(e))
              return CODE_DATABASE_ERROR
          except LoadError as e:
              Database.drop(user, password, name, host, port)
              self.error(str(e))
              return CODE_LOAD_ERROR
  
          return CMD_SUCCESS