invenio_migrator/legacy/records.py
def dump(recid,
         from_date,
         with_json=False,
         latest_only=False,
         with_collections=False,
         **kwargs):
    """Dump MARCXML and JSON representation of a record.

    :param recid: Record identifier
    :param from_date: Dump only revisions from this date onwards.
    :param with_json: If ``True`` use old ``Record.create`` to generate the
        JSON representation of the record.
    :param latest_only: Dump only the last revision of the record metadata.
    :param with_collections: If ``True`` dump the list of collections that the
        record belongs to.
    :returns: List of versions of the record.
    """
    # Grab latest only
    if latest_only:
        revision_iter = [get_record_revisions(recid, from_date)[-1]]
    else:
        revision_iter = get_record_revisions(recid, from_date)

    # Dump revisions
    record_dump = dict(
        record=[],
        files=[],
        recid=recid,
        collections=get_record_collections(recid)
        if with_collections else None, )

    for revision_date, revision_marcxml in revision_iter:
        marcxml = zlib.decompress(revision_marcxml)
        record_dump['record'].append(
            dict(
                modification_datetime=datetime_toutc(revision_date)
                .isoformat(),
                marcxml=marcxml,
                json=dump_record_json(marcxml) if with_json else None, ))

    record_dump['files'] = dump_bibdoc(recid, from_date)

    return record_dump
def dump(recid,
         from_date,
         with_json=False,
         latest_only=False,
         with_collections=False,
         **kwargs):
    """Dump MARCXML and JSON representation of a record.

    :param recid: Record identifier
    :param from_date: Dump only revisions from this date onwards.
    :param with_json: If ``True`` use old ``Record.create`` to generate the
        JSON representation of the record.
    :param latest_only: Dump only the last revision of the record metadata.
    :param with_collections: If ``True`` dump the list of collections that the
        record belongs to.
    :returns: List of versions of the record.
    """
    # Grab latest only
    if latest_only:
        revision_iter = [get_record_revisions(recid, from_date)[-1]]
    else:
        revision_iter = get_record_revisions(recid, from_date)

    # Dump revisions
    record_dump = dict(
        record=[],
        files=[],
        recid=recid,
        collections=get_record_collections(recid)
        if with_collections else None, )

    for revision_date, revision_marcxml in revision_iter:
        marcxml = zlib.decompress(revision_marcxml)
        record_dump['record'].append(
            dict(
                modification_datetime=datetime_toutc(revision_date)
                .isoformat(),
                marcxml=marcxml,
                json=dump_record_json(marcxml) if with_json else None, ))

    record_dump['files'] = dump_bibdoc(recid, from_date)

    return record_dump
def dump ( recid , from_date , with_json = False , latest_only = False , with_collections = False , * * kwargs ) : # Grab latest only if latest_only : revision_iter = [ get_record_revisions ( recid , from_date ) [ - 1 ] ] else : revision_iter = get_record_revisions ( recid , from_date ) # Dump revisions record_dump = dict ( record = [ ] , files = [ ] , recid = recid , collections = get_record_collections ( recid ) if with_collections else None , ) for revision_date , revision_marcxml in revision_iter : marcxml = zlib . decompress ( revision_marcxml ) record_dump [ 'record' ] . append ( dict ( modification_datetime = datetime_toutc ( revision_date ) . isoformat ( ) , marcxml = marcxml , json = dump_record_json ( marcxml ) if with_json else None , ) ) record_dump [ 'files' ] = dump_bibdoc ( recid , from_date ) return record_dump
Dump MARCXML and JSON representation of a record.

    :param recid: Record identifier
    :param from_date: Dump only revisions from this date onwards.
    :param with_json: If ``True`` use old ``Record.create`` to generate the
        JSON representation of the record.
    :param latest_only: Dump only the last revision of the record metadata.
    :param with_collections: If ``True`` dump the list of collections that the
        record belongs to.
    :returns: List of versions of the record.
Dump MARCXML and JSON representation of a record .