# File lib/amazon/search.rb, line 384
      def initialize(dev_token=nil, associate=nil, locale=nil, cache=nil,
                     user_agent = USER_AGENT)

        def_locale = locale
        locale = 'us' unless locale
        locale.downcase!

        configs = [ '/etc/amazonrc' ]
        configs << File.expand_path('~/.amazonrc') if ENV.key?('HOME')
        @config = {}

        configs.each do |config|
          if File.exists?(config) && File.readable?(config)
            Amazon::dprintf("Opening %s ...\n", config)

            File.open(config) { |f| lines = f.readlines }.each do |line|
              line.chomp!

              # Skip comments and blank lines
              next if line =~ /^(#|$)/

              Amazon::dprintf("Read: %s\n", line)

              # Store these, because we'll probably find a use for these later
              begin
                match = line.match(/^(\S+)\s*=\s*(['"]?)([^'"]+)(['"]?)/)
                key, begin_quote, val, end_quote = match[1,4]
                raise ConfigError if begin_quote != end_quote
              rescue NoMethodError, ConfigError
                raise ConfigError, "bad config line: #{line}"
              end

              @config[key] = val

              # Right now, we just evaluate the line, setting the variable if
              # it does not already exist
              eval line.sub(/=/, '||=')
            end
          end
        end

        # take locale from config file if no locale was passed to method
        locale = @config['locale'] if @config.key?('locale') && ! def_locale
        validate_locale(locale)

        if dev_token.nil?
          raise TokenError, 'dev_token may not be nil'
        end

        @token     = dev_token
        @id        = associate || DEFAULT_ID[locale]
        @user_agent = user_agent
        @cache     = unless cache == false
                        Amazon::Search::Cache.new(@config['cache_dir'] ||
                                                  '/tmp/amazon')
                      else
                        nil
                      end
        self.locale = locale
      end