<commit_before>from cassandra.cqlengine import connection
from cassandra.auth import PlainTextAuthProvider


class Cursor(object):
    def __init__(self, connection):
        self.connection = connection

    def execute(self, *args, **kwargs):
        return self.connection.execute(*args, **kwargs)

    def close(self):
        pass

    def fetchmany(self, _):
        return []


class FakeConnection(object):

    def commit(self):
        pass

    def rollback(self):
        pass

    def cursor(self):
        return Cursor(None)

    def close(self):
        pass


class CassandraConnection(object):

    def __init__(self, **options):

        self.hosts = options.get('HOST').split(',')
        self.keyspace = options.get('NAME')
        self.user = options.get('USER')
        self.password = options.get('PASSWORD')
        self.options = options.get('OPTIONS', {})
        self.connection_options = self.options.get('connection', {})
        self.session_options = self.options.get('session', {})

        if self.user and self.password and \
                'auth_provider' not in self.connection_options:
            self.connection_options['auth_provider'] = \
                PlainTextAuthProvider(username=self.user,
                                      password=self.password)

        self.setup()

    def setup(self):
        from cassandra.cqlengine import connection
        if connection.cluster is not None:
            # already connected
            return
        connection.setup(self.hosts, self.keyspace, **self.connection_options)

        consistency = self.connection_options.get('consistency')
        if consistency:
            self.session.default_consistency_level = consistency
        for option, value in self.session_options.items():
            setattr(self.session, option, value)

    def commit(self):
        pass

    def rollback(self):
        pass

    def cursor(self):
        return Cursor(self)

    @property
    def session(self):
        return connection.get_session()

    @property<commit_msg>Set Session attributes in class instead of local instance<commit_after>from cassandra.cluster import Session
from cassandra.cqlengine import connection
from cassandra.auth import PlainTextAuthProvider


class Cursor(object):
    def __init__(self, connection):
        self.connection = connection

    def execute(self, *args, **kwargs):
        return self.connection.execute(*args, **kwargs)

    def close(self):
        pass

    def fetchmany(self, _):
        return []


class FakeConnection(object):

    def commit(self):
        pass

    def rollback(self):
        pass

    def cursor(self):
        return Cursor(None)

    def close(self):
        pass


class CassandraConnection(object):

    def __init__(self, **options):

        self.hosts = options.get('HOST').split(',')
        self.keyspace = options.get('NAME')
        self.user = options.get('USER')
        self.password = options.get('PASSWORD')
        self.options = options.get('OPTIONS', {})
        self.connection_options = self.options.get('connection', {})
        self.session_options = self.options.get('session', {})

        if self.user and self.password and \
                'auth_provider' not in self.connection_options:
            self.connection_options['auth_provider'] = \
                PlainTextAuthProvider(username=self.user,
                                      password=self.password)

        self.setup()

    def setup(self):
        from cassandra.cqlengine import connection
        if connection.cluster is not None:
            # already connected
            return
        connection.setup(self.hosts, self.keyspace, **self.connection_options)

        consistency = self.connection_options.get('consistency')
        if consistency:
            self.session.default_consistency_level = consistency
        for option, value in self.session_options.items():
            setattr(Session, option, value)

    def commit(self):
        pass

    def rollback(self):
        pass

    def cursor(self):
        return Cursor(self)

    @property
    def session(self):
        return connection.get_session()

    @property
{'fraction_non_alphanumeric': 0.1014044275172578, 'fraction_numerical': 0.0, 'mean_word_length': 2.3589128697042367, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7042590', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1084, 'n_words': 255}