<commit_before>from pyramid.view import view_config, view_defaults
from pyramid.response import Response


@view_defaults(route_name='password_collection_view', renderer='json')
class PasswordCollectionRESTView(object):

    def __init__(self, request):
        self.request = request

    @view_config(request_method='GET')
    def get(self):
        passwords = [
            {
                'secret': '1',
                'service': 'foo',
                'account': 'pepito',
                'expiration': 0,
                'notes': '',
                'tags': [],
                },
            {
                'secret': '2',
                'service': 'bar',
                'account': 'susanita',
                'expiration': 0,
                'notes': '',
                'tags': [],
                },
            ]
        return passwords

    @view_config(request_method='POST')
    def post(self):
        return Response('post password collection')


@view_defaults(route_name='password_view', renderer='json')
class PasswordRESTView(object):

    def __init__(self, request):
        self.request = request

    @view_config(request_method='GET')
    def get(self):
        return Response('get password')

    @view_config(request_method='PUT')
    def put(self):
        return Response('put password')

    @view_config(request_method='DELETE')
    def delete(self):
        return Response('delete password')<commit_msg>Add support for the OPTIONS method, needed in CORS<commit_after>from pyramid.view import view_config, view_defaults
from pyramid.response import Response


@view_defaults(route_name='password_collection_view', renderer='json')
class PasswordCollectionRESTView(object):

    def __init__(self, request):
        self.request = request

    @view_config(request_method='OPTIONS', renderer='string')
    def options(self):
        headers = self.request.response.headers
        headers['Access-Control-Allow-Methods'] = 'GET, POST'
        headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept'
        return ''

    @view_config(request_method='GET')
    def get(self):
        passwords = [
            {
                'secret': '1',
                'service': 'foo',
                'account': 'pepito',
                'expiration': 0,
                'notes': '',
                'tags': [],
                },
            {
                'secret': '2',
                'service': 'bar',
                'account': 'susanita',
                'expiration': 0,
                'notes': '',
                'tags': [],
                },
            ]
        return passwords

    @view_config(request_method='POST')
    def post(self):
        return Response('post password collection')


@view_defaults(route_name='password_view', renderer='json')
class PasswordRESTView(object):

    def __init__(self, request):
        self.request = request

    @view_config(request_method='OPTIONS', renderer='string')
    def options(self):
        headers = self.request.response.headers
        headers['Access-Control-Allow-Methods'] = 'GET, PUT, DELETE'
        headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept'
        return ''

    @view_config(request_method='GET')
    def get(self):
        return Response('get password')

    @view_config(request_method='PUT')
    def put(self):
        return Response('put password')

    @view_config(request_method='DELETE')
    def delete(self):
        return Response('delete password')
{'fraction_non_alphanumeric': 0.1281905842314237, 'fraction_numerical': 0.0022688598979013048, 'mean_word_length': 2.2005444646098002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '894563', 'n_tokens_mistral': 992, 'n_tokens_neox': 921, 'n_words': 192}