def accept_source_changes(default_group, config, session, changes, user):
    group = changes.get('X-Debile-Group', default_group)
    suite = changes['Distribution']

    try:
        group_suite = session.query(GroupSuite).join(GroupSuite.group).join(GroupSuite.suite).filter(
            Group.name == group,
            Suite.name == suite,
        ).one()
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        return reject_changes(session, changes, "invalid-suite-for-group")

    dsc = changes.get_dsc_obj()
    if dsc['Source'] != changes['Source']:
        return reject_changes(session, changes, "dsc-does-not-march-changes")
    if dsc['Version'] != changes['Version']:
        return reject_changes(session, changes, "dsc-does-not-march-changes")

    try:
        source = session.query(Source).filter(
            Source.name == dsc['Source'],
            Source.version == dsc['Version'],
            GroupSuite.group == group_suite.group,
        ).one()
        return reject_changes(session, changes, "source-already-in-group")
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        pass

    oldsources = session.query(Source).filter(
        Source.group_suite == group_suite,
        Source.name == dsc['Source'],
    )
    for oldsource in oldsources:
        if version_compare(oldsource.version, dsc['Version']) > 0:
            return reject_changes(session, changes, "newer-source-already-in-suite")

    # Drop any old jobs that are still pending.
    for oldsource in oldsources:
        for job in oldsource.jobs:
            if (not any(job.results) and not any(job.built_binaries)):
                session.delete(job)
            elif job.failed is None:
                job.failed = True
        if not any(oldsource.jobs):
            session.delete(oldsource)

    component = session.query(Component).filter_by(name="main").one()

    if 'Build-Architecture-Indep' in dsc:
        valid_affinities = dsc['Build-Architecture-Indep']
    elif 'X-Build-Architecture-Indep' in dsc:
        valid_affinities = dsc['X-Build-Architecture-Indep']
    elif 'X-Arch-Indep-Build-Arch' not in dsc:
        valid_affinities = dsc['X-Arch-Indep-Build-Arch']
    else:
        valid_affinities = "any"

    with session.no_autoflush:
        source = create_source(dsc, group_suite, component, user,
                               config["affinity_preference"], valid_affinities)
        create_jobs(source)
        session.add(source)

        # We have a changes in order. Let's roll.
        repo = Repo(group_suite.group.repo_path)
        repo.add_changes(changes)
        try:
            (source.directory, source.dsc_filename) = repo.find_dsc(source)
        except RepoPackageNotFound:
            return reject_changes(session, changes, "reprepo-package-not-found")

    emit('accept', 'source', source.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_changes_file()] + changes.get_files():
        os.unlink(fp)
dataset/ETHPy150Open Debian/debile/debile/master/incoming_changes.py/accept_source_changes/operator `in` -> `not in`