Find the mapping given a perceval data source

    :param data_source: name of the perceval data source
    :param es_major_version: string with the major version for Elasticsearch
    :return: a dict with the mappings (raw and enriched)
498488
def find_ds_mapping(data_source, es_major_version):
    
    mappings = {"raw": None,
                "enriched": None}

    # Backend connectors
    connectors = get_connectors()

    try:
        raw_klass = connectors[data_source][1]
        enrich_klass = connectors[data_source][2]
    except KeyError:
        print("Data source not found", data_source)
        sys.exit(1)

    # Mapping for raw index
    backend = raw_klass(None)
    if backend:
        mapping = json.loads(backend.mapping.get_elastic_mappings(es_major_version)['items'])
        mappings['raw'] = [mapping, find_general_mappings(es_major_version)]

    # Mapping for enriched index
    backend = enrich_klass(None)
    if backend:
        mapping = json.loads(backend.mapping.get_elastic_mappings(es_major_version)['items'])
        mappings['enriched'] = [mapping, find_general_mappings(es_major_version)]

    return mappings
463189
def discover_datasources(datastore_str):
    
    
    datastore = DataStore(datastore_str)
    datasources=[]
    for ds in datastore.get_datasources():
        datasources.append({'text':ds.name, 'type':ds.type, 'id':ds.getHash(), 'leaf': True})
    return datasources
915333
def __get_dbms_version(self, make_connection=True):
        
        major, minor, _, _ = self.get_server_version(make_connection=make_connection)
        return '{}.{}'.format(major, minor)
1086290
def mapper(self, meta_data, instance):
        
        d = dict(meta_data)
        v = d.pop(self.aggregation_meta_data)
        instance = deepcopy(instance)
        instance.value[self.aggregation_meta_data] = v
        return instance
383824
def get_index_mapping(index):
    
    # app_path = apps.get_app_config('elasticsearch_django').path
    mappings_dir = get_setting("mappings_dir")
    filename = "%s.json" % index
    path = os.path.join(mappings_dir, filename)
    with open(path, "r") as f:
        return json.load(f)
64017
def get_mapping(self, doc_type=None, indices=None, raw=False):
        
        if doc_type is None and indices is None:
            path = make_path("_mapping")
            is_mapping = False
        else:
            indices = self.conn._validate_indices(indices)
            if doc_type:
                path = make_path(','.join(indices), doc_type, "_mapping")
                is_mapping = True
            else:
                path = make_path(','.join(indices), "_mapping")
                is_mapping = False
        result = self.conn._send_request('GET', path)
        if raw:
            return result
        from pyes.mappings import Mapper
        mapper = Mapper(result, is_mapping=False,
                        connection=self.conn,
                        document_object_field=self.conn.document_object_field)
        if doc_type:
            return mapper.mappings[doc_type]
        return mapper
1019429
def retrieve_file_handles_of_same_dataset(self, **args):
        '''
        
        '''

        mandatory_args = ['drs_id', 'version_number', 'data_node']
        esgfpid.utils.check_presence_of_mandatory_args(args, mandatory_args)
        LOGGER.debug('Looking for files of dataset "%s", version "%s".',
                     args['drs_id'], str(args['version_number']))

        if self.__switched_on:
            return self.__retrieve_file_handles_of_same_dataset(**args)
        else:
            msg = 'Cannot retrieve handles of files of the same dataset.'
            raise esgfpid.exceptions.SolrSwitchedOff(msg)
1347350
public static Map<String, DataSourceConfiguration> getDataSourceConfigurationMap(final Map<String, YamlDataSourceParameter> dataSourceParameterMap) {
        Map<String, DataSourceConfiguration> result = new LinkedHashMap<>(dataSourceParameterMap.size());
        for (Entry<String, YamlDataSourceParameter> entry : dataSourceParameterMap.entrySet()) {
            result.put(entry.getKey(), createDataSourceConfiguration(entry.getValue()));
        }
        return result;
    }
187077
def discover_datasource_columns(datastore_str, datasource_id):
    
    datastore = DataStore(datastore_str)
    datasource = datastore.get_datasource(datasource_id)
    if datasource.type != "RASTER":
        return datasource.list_columns()
    else:
        return []
340897
def project_data_source_path(cls, project, data_source):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/dataSources/{data_source}",
            project=project,
            data_source=data_source,
        )
1056098
def get_mapping_format(self):
        """"""
        if self.format == DataFormat.json or self.format == DataFormat.avro:
            return self.format.name
        else:
            return DataFormat.csv.name
1073278
def es_client(self):
        
        es_conf = self.campaign.export.elasticsearch
        return Elasticsearch(self.hosts, **es_conf.connection_params)
683079
def _get_metadap_dap(name, version=''):
    ''''''
    m = metadap(name)
    if not m:
        raise DapiCommError('DAP {dap} not found.'.format(dap=name))
    if not version:
        d = m['latest_stable'] or m['latest']
        if d:
            d = data(d)
    else:
        d = dap(name, version)
        if not d:
            raise DapiCommError(
                'DAP {dap} doesn\'t have version {version}.'.format(dap=name, version=version))
    return m, d
253590
def get_version():
    
    version_file = open(os.path.join("elasticapm", "version.py"), encoding="utf-8")
    for line in version_file:
        if line.startswith("__version__"):
            version_tuple = ast.literal_eval(line.split(" = ")[1])
            return ".".join(map(str, version_tuple))
    return "unknown"
537645
def match(self, other_version):
    
    major, minor, patch = _str_to_version(other_version, allow_wildcard=True)
    return (major in [self.major, "*"] and minor in [self.minor, "*"]
            and patch in [self.patch, "*"])
1204509
def _get_hover_data(self, data, element, dimensions=None):
        
        if 'hover' not in self.handles or self.static_source:
            return

        for d in (dimensions or element.dimensions()):
            dim = util.dimension_sanitizer(d.name)
            if dim not in data:
                data[dim] = element.dimension_values(d)
            values = np.asarray(data[dim])
            if (values.dtype.kind == 'M' or (
                    len(values) and isinstance(values[0], util.datetime_types))):
                data[dim+'_dt_strings'] = [d.pprint_value(v) for v in values]

        for k, v in self.overlay_dims.items():
            dim = util.dimension_sanitizer(k.name)
            if dim not in data:
                data[dim] = [v for _ in range(len(list(data.values())[0]))]
203199
function hasEmberVersion(major, minor) {
  const numbers = VERSION.split('-')[0].split('.');
  const actualMajor = parseInt(numbers[0], 10);
  const actualMinor = parseInt(numbers[1], 10);
  return actualMajor > major || (actualMajor === major && actualMinor >= minor);
}