<commit_before>import json

from klein import Klein


class OptOutNotFound(Exception):
    """ Raised when no opt out is found. """


class OptOutAlreadyExists(Exception):
    """ Raised when opt out already exists. """


class OptOutNotDeleted(Exception):
    """ Raised when opt out not deleted. """


class API(object):
    app = Klein()

    def __init__(self, backend):
        self._backend = backend

    def response(self, request, status_code=200, status_reason="OK", **data):
        request.setResponseCode(status_code)
        request.setHeader('Content-Type', 'application/json')
        data.update({
            "status": {
                "code": status_code,
                "reason": status_reason,
            },
        })
        return json.dumps(data)

# Error Handling

    @app.handle_errors(OptOutNotFound)
    def opt_out_not_found(self, request, failure):
        return self.response(
            request, status_code=404, status_reason="Opt out not found.")

    @app.handle_errors(OptOutAlreadyExists)
    def opt_out_already_exists(self, request, failure):
        return self.response(
            request, status_code=409, status_reason="Opt out already exists.")

    @app.handle_errors(OptOutNotDeleted)
    def opt_out_not_deleted(self, request, failure):
        return self.response(
            request, status_code=404,
            status_reason="There\'s nothing to delete.")

# Methods

    @app.route('/')
    def addresses(self, request):
            request.setHeader('Content-Type', 'application/json')
            return json.dumps(self._info)

    @app.route('/optouts/<string:addresstype>/<string:address>',
               methods=['GET'])
    def get_address(self, request, addresstype, address):
        opt_out = self._backend.get(addresstype, address)
        if opt_out is None:
            raise OptOutNotFound()
        return self.response(request, opt_out=opt_out)

    @app.route('/optouts/<string:addresstype>/<string:address>',<commit_msg>Remove broken and untested addresses route.<commit_after>import json

from klein import Klein


class OptOutNotFound(Exception):
    """ Raised when no opt out is found. """


class OptOutAlreadyExists(Exception):
    """ Raised when opt out already exists. """


class OptOutNotDeleted(Exception):
    """ Raised when opt out not deleted. """


class API(object):
    app = Klein()

    def __init__(self, backend):
        self._backend = backend

    def response(self, request, status_code=200, status_reason="OK", **data):
        request.setResponseCode(status_code)
        request.setHeader('Content-Type', 'application/json')
        data.update({
            "status": {
                "code": status_code,
                "reason": status_reason,
            },
        })
        return json.dumps(data)

# Error Handling

    @app.handle_errors(OptOutNotFound)
    def opt_out_not_found(self, request, failure):
        return self.response(
            request, status_code=404, status_reason="Opt out not found.")

    @app.handle_errors(OptOutAlreadyExists)
    def opt_out_already_exists(self, request, failure):
        return self.response(
            request, status_code=409, status_reason="Opt out already exists.")

    @app.handle_errors(OptOutNotDeleted)
    def opt_out_not_deleted(self, request, failure):
        return self.response(
            request, status_code=404,
            status_reason="There\'s nothing to delete.")

# Methods

    @app.route('/optouts/<string:addresstype>/<string:address>',
               methods=['GET'])
    def get_address(self, request, addresstype, address):
        opt_out = self._backend.get(addresstype, address)
        if opt_out is None:
            raise OptOutNotFound()
        return self.response(request, opt_out=opt_out)

    @app.route('/optouts/<string:addresstype>/<string:address>',
{'fraction_non_alphanumeric': 0.11527526492633755, 'fraction_numerical': 0.0062031532695787026, 'mean_word_length': 2.905146316851665, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 11, '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': '87285', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1097, 'n_words': 250}