<commit_before>
import psycopg2
import psycopg2.extras
import copy
import os
import json


class DbType:
    MY_SQL = "mysql"
    ORACLE = "oracle"
    POSTGRES = "pgsql"

    def __init__(self):
        pass


class DbConnectionConfig:

    host = None
    user = None
    port = "5432"
    dbname = None
    password = None
    connection_name = None
    # db_type = DbType.POSTGRES

    def __init__(self, host, dbname, user, password, connection_name, port="5432", db_type=DbType.POSTGRES):
        self.host = host
        self.port = port
        self.dbname = dbname
        self.user = user
        self.password = password
        self.connection_name = connection_name
        # self.db_type = db_type

    def save(self, config_file):
        """
        Adds current connection in a config_file.
        :param config_file: str A full path to a config file
        """

        def create_config_file(file_, content_):
            print "Create config file... ",
            try:
                f_ = open(file_, 'w+')
            except IOError as e_:
                print "Failure"
                print e_.message.decode()
                return False
            else:
                with f_:
                    f_.write(content_)

        # Convert configuration instance into a string
        connections_list = [self]
        config_string = json.dumps(connections_list, default=lambda o: o.__dict__, sort_keys=True, indent=4)

        print "Check if dbmake config file exists... ",

        if not os.path.exists(config_file):
            # Create dbmake configuration file if such not exists
            print "Not exists"
            create_config_file(config_file, config_string)

        else:
            print "Exists"
            connections_list = self.connections_list(config_file)

            print "Check if such connection is already exists... ",

            for connection in connections_list:
                if (
                    connection["connection_name"] == self.connection_name
                    or (
                        connection["host"] == self.host
                        and connection["dbname"] == self.dbname
                    )
                ):
                    print "Connection is already exists."
                    return False

            print "No"
            print "Add new connection to a config file...",

            # Add new connection to a config file
            try:
                f = open(config_file, 'w+')
            except IOError as e:
                print "Failure"
                print e.message.decode()
                return False
            else:
                with f:
                    connections_list.append(self)
                    config_string = json.dumps(connections_list, default=lambda o: o.__dict__, sort_keys=True, indent=4)
                    f.write(config_string)

            print "OK"

        return True

    @classmethod
    def delete(cls, config_file, connection_name):
        """
        Deletes a connection details from a config_file

        :param config_file: str
        :param connection_name: str
        """
        connections_list = cls.connections_list(config_file)

        for index, connection in enumerate(connections_list):
            if connection["connection_name"] == connection_name:<commit_msg>database.py:  * Add parentheses to all print cals.<commit_after>
import psycopg2
import psycopg2.extras
import copy
import os
import json


class DbType:
    MY_SQL = "mysql"
    ORACLE = "oracle"
    POSTGRES = "pgsql"

    def __init__(self):
        pass


class DbConnectionConfig:

    host = None
    user = None
    port = "5432"
    dbname = None
    password = <PASSWORD>
    connection_name = None
    # db_type = DbType.POSTGRES

    def __init__(self, host, dbname, user, password, connection_name, port="5432", db_type=DbType.POSTGRES):
        self.host = host
        self.port = port
        self.dbname = dbname
        self.user = user
        self.password = password
        self.connection_name = connection_name
        # self.db_type = db_type

    def save(self, config_file):
        """
        Adds current connection in a config_file.
        :param config_file: str A full path to a config file
        """

        def create_config_file(file_, content_):
            print("Create config file... ")
            try:
                f_ = open(file_, 'w+')
            except IOError as e_:
                print("Failure")
                print(e_.message.decode())
                return False
            else:
                with f_:
                    f_.write(content_)

        # Convert configuration instance into a string
        connections_list = [self]
        config_string = json.dumps(connections_list, default=lambda o: o.__dict__, sort_keys=True, indent=4)

        print("Check if dbmake config file exists... ")

        if not os.path.exists(config_file):
            # Create dbmake configuration file if such not exists
            print("Not exists")
            create_config_file(config_file, config_string)

        else:
            print("Exists")
            connections_list = self.connections_list(config_file)

            print("Check if such connection is already exists... ")

            for connection in connections_list:
                if (
                    connection["connection_name"] == self.connection_name
                    or (
                        connection["host"] == self.host
                        and connection["dbname"] == self.dbname
                    )
                ):
                    print("Connection is already exists.")
                    return False

            print("No")
            print("Add new connection to a config file...")

            # Add new connection to a config file
            try:
                f = open(config_file, 'w+')
            except IOError as e:
                print("Failure")
                print(e.message.decode())
                return False
            else:
                with f:
                    connections_list.append(self)
                    config_string = json.dumps(connections_list, default=lambda o: o.__dict__, sort_keys=True, indent=4)
                    f.write(config_string)

            print("OK")

        return True

    @classmethod
    def delete(cls, config_file, connection_name):
        """
        Deletes a connection details from a config_file

        :param config_file: str
        :param connection_name: str
        """
        connections_list = cls.connections_list(config_file)

        for index, connection in enumerate(connections_list):
            if connection["connection_name"] == connection_name:
{'fraction_non_alphanumeric': 0.07956225968648328, 'fraction_numerical': 0.00354924578527063, 'mean_word_length': 1.639734582357533, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2711972', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1687, 'n_words': 494}