<commit_before>import json, base64, sys, re
from lxml import etree
from datetime import datetime, timedelta
from flask import Blueprint, request, make_response
from portality.core import app
from portality.models import OAIPMHJournal, OAIPMHArticle
from portality.lib import analytics
from portality import datasets
from copy import deepcopy

blueprint = Blueprint('oaipmh', __name__)

#####################################################################
# Web API endpoints
#####################################################################


@blueprint.route("/oai", methods=["GET", "POST"])
@blueprint.route("/oai.<specified>", methods=["GET", "POST"])
def oaipmh(specified=None):
    # Google Analytics event
    event = {'category': 'OAI-PMH', 'action': None, 'label': None, 'fieldsobject': None}
    # work out which endpoint we're going to
    if specified is None:
        dao = OAIPMHJournal()
        event.label = 'Journal'
    else:
        specified = specified.lower()
        dao = OAIPMHArticle()
        event.label = 'Article'
        event.fieldsoject = {app.config.get('GA_DIMENSIONS').oai_res_id: specified}
    
    # work out the verb and associated parameters
    verb = request.values.get("verb")
    event.action = verb

    # Now we have enough information about the request to send to analytics.
    analytics.Google.send_event(**event)
    
    # call the appropriate protocol operation:
    # if no verb supplied
    if verb is None:
        result = BadVerb(request.base_url)
    
    # Identify
    elif verb.lower() == "identify":
        result = identify(dao, request.base_url)
    
    # ListMetadataFormats
    elif verb.lower() == "listmetadataformats":
        params = list_metadata_formats_params(request)
        result = list_metadata_formats(dao, request.base_url, specified, **params)
    
    # GetRecord
    elif verb.lower() == "getrecord":
        params = get_record_params(request)
        result = get_record(dao, request.base_url, specified, **params)
    
    # ListSets
    elif verb.lower() == "listsets":
        params = list_sets_params(request)
        result = list_sets(dao, request.base_url, **params)
    
    # ListRecords
    elif verb.lower() == "listrecords":<commit_msg>Stop trying to use javascript syntax for python objects<commit_after>import json, base64, sys, re
from lxml import etree
from datetime import datetime, timedelta
from flask import Blueprint, request, make_response
from portality.core import app
from portality.models import OAIPMHJournal, OAIPMHArticle
from portality.lib import analytics
from portality import datasets
from copy import deepcopy

blueprint = Blueprint('oaipmh', __name__)

#####################################################################
# Web API endpoints
#####################################################################


@blueprint.route("/oai", methods=["GET", "POST"])
@blueprint.route("/oai.<specified>", methods=["GET", "POST"])
def oaipmh(specified=None):
    # Google Analytics event
    event = {'category': 'OAI-PMH', 'action': None, 'label': None, 'fieldsobject': None}
    # work out which endpoint we're going to
    if specified is None:
        dao = OAIPMHJournal()
        event['label'] = 'Journal'
    else:
        specified = specified.lower()
        dao = OAIPMHArticle()
        event['label'] = 'Article'
        event['fieldsobject'] = {app.config.get('GA_DIMENSIONS')['oai_res_id']: specified}
    
    # work out the verb and associated parameters
    verb = request.values.get("verb")
    event['action'] = verb

    # Now we have enough information about the request to send to analytics.
    analytics.Google.send_event(**event)
    
    # call the appropriate protocol operation:
    # if no verb supplied
    if verb is None:
        result = BadVerb(request.base_url)
    
    # Identify
    elif verb.lower() == "identify":
        result = identify(dao, request.base_url)
    
    # ListMetadataFormats
    elif verb.lower() == "listmetadataformats":
        params = list_metadata_formats_params(request)
        result = list_metadata_formats(dao, request.base_url, specified, **params)
    
    # GetRecord
    elif verb.lower() == "getrecord":
        params = get_record_params(request)
        result = get_record(dao, request.base_url, specified, **params)
    
    # ListSets
    elif verb.lower() == "listsets":
        params = list_sets_params(request)
        result = list_sets(dao, request.base_url, **params)
    
    # ListRecords
    elif verb.lower() == "listrecords":
{'fraction_non_alphanumeric': 0.16351232394366197, 'fraction_numerical': 0.0008802816901408451, 'mean_word_length': 3.6567622950819674, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7187173', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1266, 'n_words': 355}