def process_changes(default_group, config, session, path):
    try:
        changes = Changes(path)
    except Exception as e:
        print('SKIP: Error loading changes file {tag} - ({exception}: {args})'.format(
            tag=path,
            exception=type(e),
            args=e.args))
        return

    try:
        changes.validate()
    except Exception as e:
        print('SKIP: Invalid changes file {tag} ({exception}: {args})'.format(
            tag=path,
            exception=type(e),
            args=e.args))
        return

    try:
        fingerprint = changes.validate_signature(config['keyrings']['pgp'])
    except ChangesFileException as e:
        return reject_changes(session, changes, "invalid-signature: " + e.message)

    group = changes.get('X-Debile-Group', default_group)
    try:
        group = session.query(Group).filter_by(name=group).one()
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        return reject_changes(session, changes, "invalid-group")

    #### Sourceful Uploads
    if changes.is_source_only_upload():
        try:
            user = session.query(Person).filter_by(pgp=fingerprint).one()
        except NoResultFound:
            return reject_changes(session, changes, "invalid-user")
        return accept_source_changes(default_group, config, session, changes, user)

    #### Binary Uploads
    if changes.is_binary_only_upload():
        try:
            builder = session.query(Builder).filter_by(pgp=fingerprint).one()
        except NoResultFound:
            return reject_changes(session, changes, "invalid-builder")
        return accept_binary_changes(default_group, config, session, changes, builder)

    return reject_changes(session, changes, "mixed-upload")
dataset/ETHPy150Open Debian/debile/debile/master/incoming_changes.py/process_changes/original