def get_bucket(self, bucket_name):
        s3_conn = self.make_s3_conn()

        bucket = s3_conn.get_bucket(bucket_name)
        if self._s3_endpoint:
            return bucket

        try:
            location = bucket.get_location()
        except boto.exception.S3ResponseError as e:
            # it's possible to have access to a bucket but not access
            # to its location metadata. This happens on the 'elasticmapreduce'
            # bucket, for example (see #1170)
            if e.status == 403:
                log.warning('Could not infer endpoint for bucket %s; '
                            'assuming %s', bucket_name, s3_conn.host)
                return bucket

            raise

        if (s3_endpoint_for_region(location) != s3_conn.host):
            s3_conn = self.make_s3_conn(location)
            bucket = s3_conn.get_bucket(bucket_name)

        return bucket
Get the bucket, connecting through the appropriate endpoint.
dataset/ETHPy150Open Yelp/mrjob/mrjob/fs/s3.py/S3Filesystem.get_bucket