<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def new(cls, script, commit, params, campaign_dir, overwrite=False):
 """ Initialize a new class instance with a set configuration and filename. The created database has the same name of the campaign directory. Args: script (str):
 the ns-3 name of the script that will be used in this campaign; commit (str):
 the commit of the ns-3 installation that is used to run the simulations. params (list):
 a list of the parameters that can be used on the script. campaign_dir (str):
 The path of the file where to save the DB. overwrite (bool):
 Whether or not existing directories should be overwritten. """


        # We only accept absolute paths
        if not Path(campaign_dir).is_absolute():
            raise ValueError("Path is not absolute")

        # Make sure the directory does not exist already
        if Path(campaign_dir).exists() and not overwrite:
            raise FileExistsError("The specified directory already exists")
        elif Path(campaign_dir).exists() and overwrite:
            # Verify we are not deleting files belonging to the user
            campaign_dir_name = os.path.basename(campaign_dir)
            folder_contents = set(os.listdir(campaign_dir))
            allowed_files = set(
                ['data', '%s.json' % campaign_dir_name] +
                # Allow hidden files (like .DS_STORE in macos)
                [os.path.basename(os.path.normpath(f)) for f in
                 glob.glob(os.path.join(campaign_dir, ".*"))])

            if(not folder_contents.issubset(allowed_files)):
                raise ValueError("The specified directory cannot be overwritten"
                                 " because it contains user files.")
            # This operation destroys data.
            shutil.rmtree(campaign_dir)

        # Create the directory and database file in it
        # The indent and separators ensure the database is human readable.
        os.makedirs(campaign_dir)
        tinydb = TinyDB(os.path.join(campaign_dir, "%s.json" %
                                     os.path.basename(campaign_dir)))

        # Save the configuration in the database
        config = {
            'script': script,
            'commit': commit,
            'params': sorted(params)
        }
        tinydb.table('config').insert(config)

        return cls(tinydb, campaign_dir)