Genera los indicadores de un catálogo individual.

    Args:
        catalog (dict): diccionario de un data.json parseado

    Returns:
        dict: diccionario con los indicadores del catálogo provisto
555650
def _generate_indicators(catalog, validator=None, only_numeric=False):
    

    result = {}

    # Obtengo summary para los indicadores del estado de los metadatos
    result.update(_generate_status_indicators(catalog, validator=validator))

    # Genero los indicadores relacionados con fechas, y los agrego
    result.update(
        _generate_date_indicators(catalog, only_numeric=only_numeric))

    # Agrego la cuenta de los formatos de las distribuciones
    if not only_numeric:
        if 'dataset' in catalog:
            format_count = count_fields(get_distributions(catalog), 'format')
            type_count = count_fields(get_distributions(catalog), 'type')
            license_count = count_fields(get_datasets(catalog), 'license')
        else:
            format_count = type_count = license_count = {}

        result.update({
            'distribuciones_formatos_cant': format_count,
            'distribuciones_tipos_cant': type_count,
            'datasets_licencias_cant': license_count,
        })

    # Agrego porcentaje de campos recomendados/optativos usados
    fields_count = _count_required_and_optional_fields(catalog)
    recomendados_pct = float(fields_count['recomendado']) / \
        fields_count['total_recomendado']
    optativos_pct = float(fields_count['optativo']) / \
        fields_count['total_optativo']
    result.update({
        'campos_recomendados_pct': round(recomendados_pct, 4),
        'campos_optativos_pct': round(optativos_pct, 4)
    })
    return fields_count, result
311787
def catalog(self):
        

        output_f = SExtractorfile(self.config['CATALOG_NAME'], 'r')
        c = output_f.read()
        output_f.close()

        return c
103917
def _get_distribution_indexes(catalog, dataset_identifier, dataset_title,
                              distribution_identifier, distribution_title,
                              logger=None):
    """"""
    logger = logger or pydj_logger
    dataset_index = _get_dataset_index(
        catalog, dataset_identifier, dataset_title)
    if dataset_index is None:
        return None, None
    else:
        dataset = catalog["catalog_dataset"][dataset_index]

    matching_distributions = []

    for idx, distribution in enumerate(dataset["dataset_distribution"]):
        if distribution["distribution_identifier"] == distribution_identifier:
            if distribution["distribution_title"] == distribution_title:
                matching_distributions.append(idx)
            else:
                logger.warning(
                    ce.DistributionUnexpectedTitle(
                        distribution_identifier,
                        distribution["distribution_title"],
                        distribution_title
                    )
                )

    # Debe haber exactamente una distribución con los identicadores provistos
    if len(matching_distributions) == 0:
        logger.warning(
            ce.DistributionTitleNonExistentError(
                distribution_title, dataset_identifier
            )
        )
        return dataset_index, None
    elif len(matching_distributions) > 1:
        logger.warning(
            ce.DistributionTitleRepetitionError(
                distribution_title, dataset_identifier, matching_distributions)
        )
        return dataset_index, None
    else:
        distribution_index = matching_distributions[0]
        return dataset_index, distribution_index
1260628
def generate_catalogue(args, parser):
    """"""
    catalogue = tacl.Catalogue()
    catalogue.generate(args.corpus, args.label)
    catalogue.save(args.catalogue)
758562
def GenerarRemito(self, id_req, archivo="qr.png"):
        ""
        if not self.remito['arrayContingencias']:
            del self.remito['arrayContingencias']
        response = self.client.generarRemito(
                                authRequest={'token': self.Token, 'sign': self.Sign, 'cuitRepresentada': self.Cuit},
                                idReq=id_req, remito=self.remito) 
        ret = response.get("generarRemitoReturn")
        if ret:
            self.__analizar_errores(ret)
            self.__analizar_observaciones(ret)
            self.__analizar_evento(ret)
            self.AnalizarRemito(ret, archivo)
        return bool(self.CodRemito)
1272373
def catalog_components(self, catalog_name, split_ver):
        
        return sorted(self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)].keys())
986550
def _get_catalog_idstrs(self):
        """"""
        if self._catalog_view == ISOLATED:
            return [str(self._catalog_id)]
        else:
            return self._get_descendent_cat_idstrs(self._catalog_id)
1284381
def select_catalogue_events(self, id0):
        '''
        
        '''
        for key in self.data.keys():
            if isinstance(
                    self.data[key], np.ndarray) and len(self.data[key]) > 0:
                # Dictionary element is numpy array - use logical indexing
                self.data[key] = self.data[key][id0]
            elif isinstance(
                    self.data[key], list) and len(self.data[key]) > 0:
                # Dictionary element is list
                self.data[key] = [self.data[key][iloc] for iloc in id0]
            else:
                continue

        if len(self.gcmts) > 0:
            self.gcmts = [self.gcmts[iloc] for iloc in id0]
            self.number_gcmts = self.get_number_tensors()
346463
def as_dict(self):
        

        result_dict = super(Profile, self).as_dict()

        statuses = list()
        version = None
        titles = list()
        descriptions = list()
        platforms = list()
        selects = list()

        for child in self.children:
            if isinstance(child, Version):
                version = child.as_dict()
            elif isinstance(child, Status):
                statuses.append(child.as_dict())
            elif isinstance(child, Title):
                titles.append(child.as_dict())
            elif isinstance(child, Description):
                descriptions.append(child.as_dict())
            elif isinstance(child, Platform):
                platforms.append(child.as_dict())
            elif isinstance(child, Select):
                selects.append(child.as_dict())

        if version is not None:
            result_dict['version'] = version
        if len(statuses) > 0:
            result_dict['statuses'] = statuses
        if len(titles) > 0:
            result_dict['titles'] = titles
        if len(descriptions) > 0:
            result_dict['descriptions'] = descriptions
        if len(platforms) > 0:
            result_dict['platforms'] = platforms
        if len(selects) > 0:
            result_dict['selects'] = selects

        return result_dict
427993
def select_catalogue_events(self, id0):
        '''
        
        '''
        for key in self.data:
            if isinstance(
                    self.data[key], np.ndarray) and len(self.data[key]) > 0:
                # Dictionary element is numpy array - use logical indexing
                self.data[key] = self.data[key][id0]
            elif isinstance(
                    self.data[key], list) and len(self.data[key]) > 0:
                # Dictionary element is list
                self.data[key] = [self.data[key][iloc] for iloc in id0]
            else:
                continue
1112496
def _build_index(self):
        """"""

        datasets_index = {}
        distributions_index = {}
        fields_index = {}

        # recorre todos los datasets
        for dataset_index, dataset in enumerate(self.datasets):
            if "identifier" in dataset:
                datasets_index[dataset["identifier"]] = {
                    "dataset_index": dataset_index
                }
                # recorre las distribuciones del dataset
                for distribution_index, distribution in enumerate(
                        dataset.get("distribution", [])):
                    if "identifier" in distribution:
                        distributions_index[distribution["identifier"]] = {
                            "distribution_index": distribution_index,
                            "dataset_identifier": dataset["identifier"]
                        }
                        # recorre los fields de la distribucion
                        for field_index, field in enumerate(
                                distribution.get("field", [])):
                            if "id" in field:
                                fields_index[field["id"]] = {
                                    "field_index":
                                        field_index,
                                    "dataset_identifier":
                                        dataset["identifier"],
                                    "distribution_identifier":
                                        distribution["identifier"]
                                }

        setattr(self, "_distributions_index", distributions_index)
        setattr(self, "_datasets_index", datasets_index)
        setattr(self, "_fields_index", fields_index)
231877
def get_categories(self, languages=None):
        
        query_parameters = {}
        if languages is not None:
            query_parameters['languages'] = self._serialize.query('languages', languages, 'str')
        response = self._send(http_method='GET',
                              location_id='e0a5a71e-3ac3-43a0-ae7d-0bb5c3046a2a',
                              version='5.1-preview.1',
                              query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))
616070
def build_catalog_info(self, catalog_info):
        
        cat = SourceFactory.build_catalog(**catalog_info)
        catalog_info['catalog'] = cat
        # catalog_info['catalog_table'] =
        #    Table.read(catalog_info['catalog_file'])
        catalog_info['catalog_table'] = cat.table
        catalog_info['roi_model'] =\
            SourceFactory.make_fermipy_roi_model_from_catalogs([cat])
        catalog_info['srcmdl_name'] =\
            self._name_factory.srcmdl_xml(sourcekey=catalog_info['catalog_name'])
        return CatalogInfo(**catalog_info)
597949
def json(self, with_candidates=False):
        

        def _json_or_none(obj):
            return None if obj is None else obj.json()

        data = {
            "status": self.status,
            "method_name": self.method_name,
            "interval": self.interval,
            "model": _json_or_none(self.model),
            "r_squared_adj": _noneify(self.r_squared_adj),
            "warnings": [w.json() for w in self.warnings],
            "metadata": self.metadata,
            "settings": self.settings,
            "totals_metrics": _json_or_none(self.totals_metrics),
            "avgs_metrics": _json_or_none(self.avgs_metrics),
            "candidates": None,
        }
        if with_candidates:
            data["candidates"] = [candidate.json() for candidate in self.candidates]
        return data
321103
def concatenate(self, catalogue):
        

        atts = getattr(self, 'data')
        attn = getattr(catalogue, 'data')
        data = _merge_data(atts, attn)

        if data is not None:
            setattr(self, 'data', data)
            for attrib in vars(self):
                atts = getattr(self, attrib)
                attn = getattr(catalogue, attrib)
                if attrib is 'end_year':
                    setattr(self, attrib, max(atts, attn))
                elif attrib is 'start_year':
                    setattr(self, attrib, min(atts, attn))
                elif attrib is 'data':
                    pass
                elif attrib is 'number_earthquakes':
                    setattr(self, attrib, atts + attn)
                elif attrib is 'processes':
                    if atts != attn:
                        raise ValueError('The catalogues cannot be merged' +
                                         ' since the they have' +
                                         ' a different processing history')
                else:
                    raise ValueError('unknown attribute: %s' % attrib)
        self.sort_catalogue_chronologically()
997648
def get_catalog_path(catalog_id, catalogs_dir=CATALOGS_DIR, fmt="json"):
    """"""

    base_path = os.path.join(catalogs_dir, "catalog", catalog_id)
    if fmt == "json":
        return os.path.join(base_path, "data.json")
    elif fmt == "xlsx":
        return os.path.join(base_path, "catalog.xlsx")
    else:
        raise NotImplementedError("El formato {} no está implementado.".format(
            fmt))
1236720
def make_query(catalog):
    
    query = {}
    request = api.get_request()
    index = get_search_index_for(catalog)
    limit = request.form.get("limit")

    q = request.form.get("q")
    if len(q) > 0:
        query[index] = q + "*"
    else:
        return None

    portal_type = request.form.get("portal_type")
    if portal_type:
        if not isinstance(portal_type, list):
            portal_type = [portal_type]
        query["portal_type"] = portal_type

    if limit and limit.isdigit():
        query["sort_limit"] = int(limit)

    return query