<commit_before>from webservice.NexusHandler import NexusHandler as BaseHandler
from webservice.webmodel import StatsComputeOptions
from webservice.NexusHandler import nexus_handler
from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC
from webservice.webmodel import NexusResults, NexusProcessingException
import BaseDomsHandler
import datafetch
import config

@nexus_handler
class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler):

    name = "DOMS Dataset Listing"
    path = "/domslist"
    description = ""
    params = {}
    singleton = True

    def __init__(self):
        BaseHandler.__init__(self)

    def calc(self, computeOptions, **args):

        satellitesList = self._tile_service.get_dataseries_list()

        insituList = []

        for insitu in config.ENDPOINTS:
            insituList.append({
                "name" : insitu["name"],
                "endpoint" : insitu["url"]
            })


        values = {
            "satellite" : satellitesList,
            "insitu" : insituList
        }

        return BaseDomsHandler.DomsQueryResults(results=values)<commit_msg>Adding metadata to list results<commit_after>from webservice.NexusHandler import NexusHandler as BaseHandler
from webservice.webmodel import StatsComputeOptions
from webservice.NexusHandler import nexus_handler
from webservice.NexusHandler import DEFAULT_PARAMETERS_SPEC
from webservice.webmodel import NexusResults, NexusProcessingException, DatasetNotFoundException
import BaseDomsHandler
import datafetch
import config
import requests
import json

@nexus_handler
class DomsDatasetListQueryHandler(BaseDomsHandler.BaseDomsQueryHandler):

    name = "DOMS Dataset Listing"
    path = "/domslist"
    description = ""
    params = {}
    singleton = True

    def __init__(self):
        BaseHandler.__init__(self)


    def __getUrlForDataset(self, dataset):
        datasetSpec = config.getEndpointByName(dataset)
        if datasetSpec is not None:
            return datasetSpec["metadataUrl"]
        else:
            return "http://doms.jpl.nasa.gov/ws/metadata/dataset?shortName=%s&format=umm-json"%dataset

    def getMetadataForSource(self, dataset):
        try:
            r = requests.get(self.__getUrlForDataset(dataset))
            results = json.loads(r.text)
            return results
        except:
            return None

    def calc(self, computeOptions, **args):

        satellitesList = self._tile_service.get_dataseries_list()

        insituList = []

        for satellite in satellitesList:
            satellite["metadata"] = self.getMetadataForSource(satellite["shortName"])


        for insitu in config.ENDPOINTS:
            insituList.append({
                "name" : insitu["name"],
                "endpoint" : insitu["url"],
                "metadata": self.getMetadataForSource(insitu["name"])
            })


        values = {
            "satellite" : satellitesList,
            "insitu" : insituList
        }

        return BaseDomsHandler.DomsQueryResults(results=values)
{'fraction_non_alphanumeric': 0.08038057742782152, 'fraction_numerical': 0.0, 'mean_word_length': 2.9546044098573283, 'pattern_counts': {'":': 1, '<': 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': '252244', 'n_tokens_mistral': 856, 'n_tokens_neox': 825, 'n_words': 180}