docstr: Get the credentials for an AWS S3 bucket from the config
  :param base_url: URL of bucket
  :param extra_configurations:
  :return: bucket config
docstr_tok: ["Get","the","credentials","for","an","AWS","S3","bucket","from","the","config",":","param","base_url",":","URL","of","bucket",":","param","extra_configurations",":",":","return",":","bucket","config"]
code: def get_config_for_bucket(self, base_url, extra_configurations=None):
      """
      Get the credentials for an AWS S3 bucket from the config
      :param base_url: URL of bucket
      :param extra_configurations:
      :return: bucket config
      """
  
      warnings.warn(
          "Use backend_config.bucket_config.BucketList.get_config_for_uri",
          DeprecationWarning,
      )
      configs = S3BucketConfig.from_list(
          self.get("sdk.aws.s3.credentials", [])
      )
      if extra_configurations:
          configs.extend(extra_configurations)
  
      def find_match(host=None, bucket=None):
          if not host and not bucket:
              raise ValueError("host or bucket required")
          try:
              if host:
                  res = {
                      config
                      for config in configs
                      if (config.host and fnmatch(host, config.host))
                      and (
                          not bucket
                          or not config.bucket
                          or fnmatch(
                              bucket.lower(), config.bucket.lower()
                          )
                      )
                  }
              else:
                  res = {
                      config
                      for config in configs
                      if config.bucket
                      and fnmatch(bucket.lower(), config.bucket.lower())
                  }
              return next(iter(res))
          except StopIteration:
              pass
  
      parsed = urlparse(base_url)
      parts = Path(parsed.path.strip("/")).parts
      if parsed.netloc:
          # We have a netloc (either an actual hostname or an AWS bucket name).
          # First, we'll try with the netloc as host, but if we don't find anything, we'll try without a host and
          # with the netloc as the bucket name
          match = None
          if parts:
              # try host/bucket only if path parts contain any element
              match = find_match(host=parsed.netloc, bucket=parts[0])
          if not match:
              # no path parts or no config found for host/bucket, try netloc as bucket
              match = find_match(bucket=parsed.netloc)
      else:
          # No netloc, so we'll simply search by bucket
          match = find_match(bucket=parts[0])
  
      if match:
          return match
  
      non_aws_s3_host_suffix = ":9000"
      if parsed.netloc.endswith(non_aws_s3_host_suffix):
          host = parsed.netloc
          bucket = parts[0] if parts else None
      else:
          host = None
          bucket = parsed.netloc
  
      return S3BucketConfig(
          key=self.get("sdk.aws.s3.key", None),
          secret=self.get("sdk.aws.s3.secret", None),
          region=self.get("sdk.aws.s3.region", None),
          use_credentials_chain=self.get(
              "sdk.aws.s3.use_credentials_chain", None
          ),
          multipart=True,
          bucket=bucket,
          host=host,
          extra_args=self.get("sdk.aws.s3.extra_args", None),
      )
  
imports: from __future__ import print_function
  import functools
  import json
  import logging
  import os
  import sys
  import warnings
  from fnmatch import fnmatch
  from os.path import expanduser
  from typing import Any
  import six
  from pathlib2 import Path
  from pyparsing import ParseFatalException, ParseException, RecursiveGrammarException, ParseSyntaxException
  from six.moves.urllib.parse import urlparse
  from .bucket_config import S3BucketConfig
  from .defs import Environment, DEFAULT_CONFIG_FOLDER, LOCAL_CONFIG_PATHS, ENV_CONFIG_PATHS, LOCAL_CONFIG_FILES, LOCAL_CONFIG_FILE_OVERRIDE_VAR, ENV_CONFIG_PATH_OVERRIDE_VAR, CONFIG_VERBOSE
  from .defs import is_config_file
  from .entry import Entry, NotSet
  from .errors import ConfigurationError
  from .log import initialize, logger
  from .utils import get_options
  from ..utilities.pyhocon import ConfigTree, ConfigFactory
label_desc: Use image node_id 20 for calling the Config obj's underlying member method code with example usage: obj.get_config_for_bucket(base_url, extra_configurations) and returns: S3BucketConfig, match, next