<commit_before>from boto.exception import *
from boto.s3.connection import *
from boto.s3.cors import CORSConfiguration

from hurry.filesize import size, alternative

import os
import re
from boto.iam import *
from datetime import datetime


#Note: (from boto docs) this function is in beta
def enable_versioning(settings):
    wrapper = S3Wrapper.from_addon(settings)
    wrapper.bucket.configure_versioning(True)


def has_access(access_key, secret_key):
    try:
        c = S3Connection(access_key, secret_key)
        c.get_all_buckets()
        return True
    except Exception:
        return False


def get_bucket_list(user_settings):
        return S3Connection(user_settings.access_key, user_settings.secret_key).get_all_buckets()


def create_bucket(user_settings, bucket_name):
    try:
        connect = S3Connection(
            user_settings.access_key, user_settings.secret_key)
        return connect.create_bucket(bucket_name)
    except Exception:
        return False


def does_bucket_exist(accessKey, secretKey, bucketName):
    try:
        c = S3Connection(accessKey, secretKey)
        c.get_bucket(bucketName, validate=false)
        return True
    except Exception:
        return False


class S3Wrapper:

    @classmethod
    def from_addon(cls, s3):
        if not s3.is_registration:
            return cls(S3Connection(s3.user_settings.access_key, s3.user_settings.secret_key), s3.bucket)
        else:
            return registration_wrapper(s3)

    @classmethod
    def bucket_exist(cls, s3, bucketName):<commit_msg>Fix bug in selecting s3 bucket<commit_after>from boto.exception import *
from boto.s3.connection import *
from boto.s3.cors import CORSConfiguration

from hurry.filesize import size, alternative

import os
import re
from boto.iam import *
from datetime import datetime


#Note: (from boto docs) this function is in beta
def enable_versioning(settings):
    wrapper = S3Wrapper.from_addon(settings)
    wrapper.bucket.configure_versioning(True)


def has_access(access_key, secret_key):
    try:
        c = S3Connection(access_key, secret_key)
        c.get_all_buckets()
        return True
    except Exception:
        return False


def get_bucket_list(user_settings):
        return S3Connection(user_settings.access_key, user_settings.secret_key).get_all_buckets()


def create_bucket(user_settings, bucket_name):
    try:
        connect = S3Connection(
            user_settings.access_key, user_settings.secret_key)
        return connect.create_bucket(bucket_name)
    except Exception:
        return False


def does_bucket_exist(accessKey, secretKey, bucketName):
    try:
        c = S3Connection(accessKey, secretKey)
        c.get_bucket(bucketName, validate=False)
        return True
    except Exception:
        return False


class S3Wrapper:

    @classmethod
    def from_addon(cls, s3):
        if not s3.is_registration:
            return cls(S3Connection(s3.user_settings.access_key, s3.user_settings.secret_key), s3.bucket)
        else:
            return registration_wrapper(s3)

    @classmethod
    def bucket_exist(cls, s3, bucketName):
{'fraction_non_alphanumeric': 0.07172590457893052, 'fraction_numerical': 0.010566762728146013, 'mean_word_length': 3.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3482373', 'n_tokens_mistral': 957, 'n_tokens_neox': 934, 'n_words': 224}