Beispiel #1
0
    def check(self, metadata):
        """Enriquece e normaliza itens do dicionário ``metadata``, que representa
        metadados de um periódico.

        A estrutura de ``metadata`` é a mesma retornada pelo formato JSON, do
        ``articlemeta.scielo.org``, conforme exemplo:
        https://gist.github.com/gustavofonseca/92638fe6e1f85dd84bcebce72e83b76e
        """
        metadata_copy = metadata.copy()
        journal = Journal(metadata_copy)

        issns = set([
            journal.any_issn(priority=u'electronic'),
            journal.any_issn(priority=u'print'),
            journal.scielo_issn
        ])

        metadata_copy['code'] = journal.scielo_issn
        metadata_copy['issns'] = list(issns)
        metadata_copy['collection'] = journal.collection_acronym

        if not isinstance(journal.data['processing_date'], datetime):
            try:
                metadata_copy['processing_date'] = datetime.strptime(journal.data['processing_date'], '%Y-%m-%d')
            except:
                metadata_copy['processing_date'] = datetime.now()

        return metadata_copy
Beispiel #2
0
    def check(self, metadata):
        """Enriquece e normaliza itens do dicionário ``metadata``, que representa
        metadados de um periódico.

        A estrutura de ``metadata`` é a mesma retornada pelo formato JSON, do
        ``articlemeta.scielo.org``, conforme exemplo:
        https://gist.github.com/gustavofonseca/92638fe6e1f85dd84bcebce72e83b76e
        """
        metadata_copy = metadata.copy()
        journal = Journal(metadata_copy)

        issns = set([
            journal.any_issn(priority=u'electronic'),
            journal.any_issn(priority=u'print'), journal.scielo_issn
        ])

        metadata_copy['code'] = journal.scielo_issn
        metadata_copy['issns'] = list(issns)
        metadata_copy['collection'] = journal.collection_acronym

        if not isinstance(journal.data['processing_date'], datetime):
            try:
                metadata_copy['processing_date'] = datetime.strptime(
                    journal.data['processing_date'], '%Y-%m-%d')
            except:
                metadata_copy['processing_date'] = datetime.now()

        return metadata_copy
    def _check_journal_meta(self, metadata):
        """
            This method will check the given metadata and retrieve
            a new dictionary with some new fields.
        """
        journal = Journal(metadata)

        issns = set([journal.any_issn(priority=u"electronic"), journal.any_issn(priority=u"print")])

        metadata["code"] = list(issns)
        metadata["collection"] = journal.collection_acronym

        return metadata
Beispiel #4
0
    def _check_journal_meta(self, metadata):
        """
            This method will check the given metadata and retrieve
            a new dictionary with some new fields.
        """
        journal = Journal(metadata)

        issns = set([
            journal.any_issn(priority=u'electronic'),
            journal.any_issn(priority=u'print'), journal.scielo_issn
        ])

        metadata['code'] = journal.scielo_issn
        metadata['issns'] = list(issns)
        metadata['collection'] = journal.collection_acronym

        return metadata
Beispiel #5
0
    def _check_journal_meta(self, metadata):
        """
            This method will check the given metadata and retrieve
            a new dictionary with some new fields.
        """
        journal = Journal(metadata)

        issns = set([
            journal.any_issn(priority=u'electronic'),
            journal.any_issn(priority=u'print'),
            journal.scielo_issn
        ])

        metadata['code'] = journal.scielo_issn
        metadata['issns'] = list(issns)
        metadata['collection'] = journal.collection_acronym

        return metadata
    def _check_journal_meta(self, metadata):
        """
            This method will check the given metadata and retrieve
            a new dictionary with some new fields.
        """
        journal = Journal(metadata)

        issns = set([
            journal.any_issn(priority=u'electronic'),
            journal.any_issn(priority=u'print'),
            journal.scielo_issn
        ])

        metadata['code'] = journal.scielo_issn
        metadata['issns'] = list(issns)
        metadata['collection'] = journal.collection_acronym

        if not isinstance(journal.processing_date, datetime):
            try:
                metadata['processing_date'] = datetime.strptime(journal.processing_date, '%Y-%m-%d')
            except:
                metadata['processing_date'] = datetime.now()

        return metadata
def journal_as_kernel(journal: Journal) -> dict:
    """Gera um dicionário com a estrutura esperada pela API do Kernel a
    partir da estrutura gerada pelo isis2json"""

    _payload = {}
    _id = journal.any_issn()

    if not _id:
        _id = journal.scielo_issn

    _payload["_id"] = _id

    if journal.mission:
        _payload["mission"] = [{
            "language": lang,
            "value": value
        } for lang, value in journal.mission.items()]
    else:
        _payload["mission"] = []

    _payload["title"] = journal.title or ""
    _payload["title_iso"] = journal.abbreviated_iso_title or ""
    _payload["short_title"] = journal.abbreviated_title or ""
    _payload["acronym"] = journal.acronym or ""
    _payload["scielo_issn"] = journal.scielo_issn or ""
    _payload["print_issn"] = journal.print_issn or ""
    _payload["electronic_issn"] = journal.electronic_issn or ""

    _payload["status"] = {}
    if journal.status_history:
        _status = journal.status_history[-1]
        _payload["status"]["status"] = _status[1]

        if _status[2]:
            _payload["status"]["reason"] = _status[2]

    _payload["subject_areas"] = []
    if journal.subject_areas:

        for subject_area in journal.subject_areas:
            # TODO: Algumas áreas estão em caixa baixa, o que devemos fazer?

            # A Base MST possui uma grande área que é considerada errada
            # é preciso normalizar o valor
            if subject_area.upper() == "LINGUISTICS, LETTERS AND ARTS":
                subject_area = "LINGUISTIC, LITERATURE AND ARTS"

            _payload["subject_areas"].append(subject_area.upper())

    _payload["sponsors"] = []
    if journal.sponsors:
        _payload["sponsors"] = [{
            "name": sponsor
        } for sponsor in journal.sponsors]

    _payload["subject_categories"] = journal.wos_subject_areas or []
    _payload["online_submission_url"] = journal.submission_url or ""

    _payload["next_journal"] = {}
    if journal.next_title:
        _payload["next_journal"]["name"] = journal.next_title

    _payload["previous_journal"] = {}
    if journal.previous_title:
        _payload["previous_journal"]["name"] = journal.previous_title

    _payload["contact"] = {}
    if journal.editor_email:
        _payload["contact"]["email"] = journal.editor_email

    if journal.editor_address:
        _payload["contact"]["address"] = journal.editor_address

    return _payload