def modify_file_dealing_with_branch_protection(self, project_and_group, branch, file, operation, configuration, new_content=None):
    try:
        self.just_modify_file(project_and_group, branch, file, operation, configuration, new_content)
    except UnexpectedResponseException as e:
        if ((e.response_status_code == 400) and ('You are not allowed to push into this branch' in e.response_text)):
            if configuration.get((('branches|' + branch) + '|protected')):
                debug(f'> Temporarily unprotecting the branch to {operation} a file in it...')
                self.branch_protector.unprotect_branch(project_and_group, branch)
            else:
                fatal(f"Operation {operation} on file {file} in branch {branch} not permitted, but we don't have a branch protection configuration provided for this branch. Breaking as we cannot unprotect the branch as we would not know how to protect it again.", EXIT_INVALID_INPUT)
            try:
                self.just_modify_file(project_and_group, branch, file, operation, configuration, new_content)
            finally:
                if configuration.get((('branches|' + branch) + '|protected')):
                    debug('> Protecting the branch again.')
                    self.branch_protector.protect_branch(project_and_group, configuration, branch)
        else:
            raise e
def modify_file_dealing_with_branch_protection(self, project_and_group, branch, file, operation, configuration, new_content=None):
    try:
        self.just_modify_file(project_and_group, branch, file, operation, configuration, new_content)
    except UnexpectedResponseException as e:
        if ((e.response_status_code == 400) and ('You are not allowed to push into this branch' in e.response_text)):
            if configuration.get((('branches|' + branch) + '|protected')):
                debug(f'> Temporarily unprotecting the branch to {operation} a file in it...')
                self.branch_protector.unprotect_branch(project_and_group, branch)
            else:
                fatal(f"Operation {operation} on file {file} in branch {branch} not permitted, but we don't have a branch protection configuration provided for this branch. Breaking as we cannot unprotect the branch as we would not know how to protect it again.", EXIT_INVALID_INPUT)
            try:
                self.just_modify_file(project_and_group, branch, file, operation, configuration, new_content)
            finally:
                if configuration.get((('branches|' + branch) + '|protected')):
                    debug('> Protecting the branch again.')
                    self.branch_protector.protect_branch(project_and_group, configuration, branch)
        else:
            raise e