from ..schema import SchemaOverdo def add_book_info(record, blob): """Add link to the appropriate book record.""" collections = [] if 'collections' in record: for c in record.get('collections', ''): if c.get('primary', ''): collections.append(c.get('primary').lower()) if 'bookchapter' in collections: pubinfos = force_list(blob.get("773__", [])) for pubinfo in pubinfos: if pubinfo.get('0'): record['book'] = { 'record': inspire_dojson_utils.get_record_ref( int(force_list(pubinfo.get('0'))[0]), 'literature') } class Publication(SchemaOverdo): def do(self, blob, **kwargs): output = super(Publication, self).do(blob, **kwargs) add_book_info(output, blob) return output hep = Publication(schema="hep.json", entry_point_group="inspirehep.dojson.hep") hep2marc = Overdo(entry_point_group="inspirehep.dojson.hep2marc")
# along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, RERO does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. """rero-ils MARC21 model definition.""" import re import sys import requests from dojson import Overdo, utils marc21tojson = Overdo() def remove_punctuation(data): """Remove punctuation from data.""" try: if data[-1:] == ',': data = data[:-1] if data[-2:] == ' :': data = data[:-2] if data[-2:] == ' ;': data = data[:-2] if data[-2:] == ' /': data = data[:-2] if data[-2:] == ' -': data = data[:-2]
# along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, RERO does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. """reroils-data MARC21 model definition.""" import re from dojson import Overdo, utils from isbnlib import EAN13 marc21 = Overdo() def remove_punctuation(data): """Remove punctuation from data.""" try: if data[-1:] == ',': data = data[:-1] if data[-2:] == ' :': data = data[:-2] if data[-2:] == ' ;': data = data[:-2] if data[-2:] == ' /': data = data[:-2] if data[-2:] == ' -': data = data[:-2]
# -*- coding: utf-8 -*- # # Copyright (C) 2018 RERO. # # RERO Ebooks is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Marc21 data conversion.""" from dojson import Overdo, utils marc21 = Overdo(entry_point_group='rero_ebooks.marc21') """MARC 21 Format for Bibliographic Data.""" @marc21.over('__order__', '__order__') def order(self, key, value): """Preserve order of datafields.""" order = [] for field in value: name = marc21.index.query(field) if name: name = name[0] else: name = field order.append(name) return order
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """rero-ils UNIMARC model definition.""" import re from json import loads from dojson import Overdo, utils # from dojson.utils import force_list from pkg_resources import resource_string unimarctojson = Overdo() # @unimarctojson.over('__order__', '__order__') # def order(self, key, value): # """Preserve order of datafields.""" # order = [] # for field in value: # name = unimarctojson.index.query(field) # if name: # name = name[0] # else: # name = field # order.append(name) # # return order
# -*- coding: utf-8 -*- # # This file is part of DoJSON # Copyright (C) 2015 CERN. # # DoJSON is free software; you can redistribute it and/or # modify it under the terms of the Revised BSD License; see LICENSE # file for more details. """MARC 21 model definition.""" from dojson import Overdo, utils marc21 = Overdo(entry_point_group='dojson.contrib.marc21') """MARC 21 Format for Bibliographic Data.""" @marc21.over('__order__', '__order__') def order(self, key, value): """Preserve order of datafields.""" order = [] for field in value: name = marc21.index.query(field) if name: name = name[0] else: name = field order.append(name) return order
# -*- coding: utf-8 -*- # # This file is part of INSPIRE. # Copyright (C) 2015 CERN. # # INSPIRE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # INSPIRE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with INSPIRE. If not, see <http://www.gnu.org/licenses/>. # # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. """Models related to INSPIRE legacy workflow metadata.""" from dojson import Overdo bibfield = Overdo() author_bibfield = Overdo()
return GroupableOrderedDict(output) def add_book_info(record, blob): """Add link to the appropriate book record.""" collections = [] if 'collections' in record: for c in record.get('collections', ''): if c.get('primary', ''): collections.append(c.get('primary').lower()) if 'bookchapter' in collections: pubinfos = force_list(blob.get("773__", [])) for pubinfo in pubinfos: if pubinfo.get('0'): record['book'] = { 'record': get_record_ref( int(force_list(pubinfo.get('0'))[0]), 'literature') } class Publication(SchemaOverdo): def do(self, blob, **kwargs): output = super(Publication, self).do(blob, **kwargs) add_book_info(output, blob) return output hep = Overdo(entry_point_group="scoap3.dojson.hep") hep2marc = Underdo(entry_point_group="scoap3.dojson.hep2marc")
# -*- coding: utf-8 -*- # # This file is part of DoJSON # Copyright (C) 2015 CERN. # Copyright (C) 2020 Graz University of Technology. # # DoJSON is free software; you can redistribute it and/or # modify it under the terms of the Revised BSD License; see LICENSE # file for more details. """MARC 21 model definition.""" from dojson import Overdo, utils marc21 = Overdo(entry_point_group="dojson.contrib.marc21") """MARC 21 Format for Bibliographic Data.""" marc21_authority = Overdo(entry_point_group="dojson.contrib.marc21_authority") """MARC 21 Format for Authority Data.""" @marc21.over("__order__", "__order__") def order(self, key, value): """Preserve order of datafields.""" order = [] for field in value: name = marc21.index.query(field) if name: name = name[0] else: name = field order.append(name)
# -*- coding: utf-8 -*- # # This file is part of INSPIRE. # Copyright (C) 2015 CERN. # # INSPIRE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # INSPIRE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with INSPIRE. If not, see <http://www.gnu.org/licenses/>. # # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. """Models related to INSPIRE depositions.""" from dojson import Overdo updateform = Overdo()
# -*- coding: utf-8 -*- # # This file is part of INSPIRE. # Copyright (C) 2014, 2015, 2016 CERN. # # INSPIRE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # INSPIRE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with INSPIRE. If not, see <http://www.gnu.org/licenses/>. # # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. """institutions model definition.""" from dojson import Overdo from ..schema import SchemaOverdo hepnames = SchemaOverdo(schema="authors.json") hepnames2marc = Overdo()
import types from dojson import Overdo from dojson.utils import force_list def add_book_info(record, blob): """Add link to the appropriate book record.""" if 'collections' in record: collections = [c['primary'].lower() for c in record['collections'] if 'primary' in c] if 'bookchapter' in collections: pubinfos = force_list(blob.get("773__", [])) for pubinfo in pubinfos: if pubinfo.get('0'): record['book'] = { 'recid': int(pubinfo['0']) } def custom_do(self, blob): """Custom do function that allows extra post-processing.""" record = self._do(blob) add_book_info(record, blob) return record hep = Overdo() hep._do = hep.do hep.do = types.MethodType(custom_do, hep) hep2marc = Overdo()
# -*- coding: utf-8 -*- """MARC 21 model definition.""" import copy import re from dojson import Overdo, utils from . import utils as myutils from .utils import lang2ln, ln2lang book = Overdo() book2marc = Overdo() class BadDateFormatException(Exception): """Bad date format custom Exception.""" pass def get_number_of_pages(value): """Retrive number of pages in a given string.""" raw_pages = value.get('a') if not raw_pages: return None n_pages = re.findall(r'(\d+)\s*(?:p|s|f)', raw_pages, re.IGNORECASE) if n_pages: return int(n_pages[0]) else:
# -*- coding: utf-8 -*- # # This file is part of INSPIRE. # Copyright (C) 2015 CERN. # # INSPIRE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # INSPIRE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with INSPIRE. If not, see <http://www.gnu.org/licenses/>. # # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. """Models related to INSPIRE depositions.""" from dojson import Overdo literature = Overdo()