示例#1
0
    def _create_marc(self, records_xml):
        """Creates MARC from MARCXML.

        @param records_xml: MARCXML containing information about the records

        @return: string containing information about the records
        in MARC format
        """
        aleph_marc_output = ""

        records = bibrecord.create_records(records_xml)
        for (record, status_code, list_of_errors) in records:
            sysno_options = {"text-marc": 1}
            sysno = xmlmarc2textmarc.get_sysno_from_record(
                record, sysno_options)
            options = {
                "aleph-marc": 0,
                "correct-mode": 1,
                "append-mode": 0,
                "delete-mode": 0,
                "insert-mode": 0,
                "replace-mode": 0,
                "text-marc": 1
            }
            aleph_record = xmlmarc2textmarc.create_marc_record(
                record, sysno, options)
            aleph_marc_output += aleph_record

        return aleph_marc_output
示例#2
0
def _create_marc(records_xml):
    """Creates MARC from MARCXML.

    @param records_xml: MARCXML containing information about the records

    @return: string containing information about the records
    in MARC format
    """
    aleph_marc_output = ""

    records = bibrecord.create_records(records_xml)
    for (record, status_code, list_of_errors) in records:
        # The system number is in field 970a
        # By this reason it should exist in the MARC XML
        # otherwise it will be None in the output ALEPH marc
        sysno_options = {"text-marc": 0}
        sysno = xmlmarc2textmarc.get_sysno_from_record(record, sysno_options)

        if sysno == None:
            sysno = ""

        options = {
            "aleph-marc": 0,
            "correct-mode": 1,
            "append-mode": 0,
            "delete-mode": 0,
            "insert-mode": 0,
            "replace-mode": 0,
            "text-marc": 1
        }
        aleph_record = xmlmarc2textmarc.create_marc_record(
            record, sysno, options)
        aleph_marc_output += aleph_record

    return aleph_marc_output
示例#3
0
def _create_marc(records_xml):
    """Creates MARC from MARCXML.

    @param records_xml: MARCXML containing information about the records

    @return: string containing information about the records
    in MARC format
    """
    aleph_marc_output = ""

    records = bibrecord.create_records(records_xml)
    for (record, status_code, list_of_errors) in records:
        # The system number is in field 970a
        # By this reason it should exist in the MARC XML
        # otherwise it will be None in the output ALEPH marc
        sysno_options = {"text-marc":0}
        sysno = xmlmarc2textmarc.get_sysno_from_record(record,
                                                       sysno_options)

        if sysno == None:
            sysno = ""

        options = {"aleph-marc":0, "correct-mode":1, "append-mode":0,
                   "delete-mode":0, "insert-mode":0, "replace-mode":0,
                   "text-marc":1}
        aleph_record = xmlmarc2textmarc.create_marc_record(record,
                                                           sysno,
                                                           options)
        aleph_marc_output += aleph_record

    return aleph_marc_output
def transform_record_to_marc(record, options={'text-marc':1, 'aleph-marc':0}):
    """ This function will transform a given bibrec record into marc using
    methods from xmlmarc2textmarc in invenio.textutils. The function returns the
    record as a MARC string.

    @param record: bibrec structure for record to transform
    @type record: dict

    @param options: dictionary describing type of MARC record. Defaults to textmarc.
    @type options: dict

    @return resulting MARC record as string """
    sysno = get_sysno_from_record(record, options)
    # Note: Record dict is copied as create_marc_record() perform deletions
    return create_marc_record(record.copy(), sysno, options)
示例#5
0
def transform_record_to_marc(record,
                             options={
                                 'text-marc': 1,
                                 'aleph-marc': 0
                             }):
    """ This function will transform a given bibrec record into marc using
    methods from xmlmarc2textmarc in invenio.textutils. The function returns the
    record as a MARC string.

    @param record: bibrec structure for record to transform
    @type record: dict

    @param options: dictionary describing type of MARC record. Defaults to textmarc.
    @type options: dict

    @return resulting MARC record as string """
    sysno = get_sysno_from_record(record, options)
    # Note: Record dict is copied as create_marc_record() perform deletions
    return create_marc_record(record.copy(), sysno, options)
    def _create_marc(self, records_xml):
        """Creates MARC from MARCXML.

        @param records_xml: MARCXML containing information about the records

        @return: string containing information about the records
        in MARC format
        """
        aleph_marc_output = ""

        records = bibrecord.create_records(records_xml)
        for (record, status_code, list_of_errors) in records:
            sysno_options = {"text-marc":1}
            sysno = xmlmarc2textmarc.get_sysno_from_record(record,
                                                              sysno_options)
            options = {"aleph-marc":0, "correct-mode":1, "append-mode":0,
                       "delete-mode":0, "insert-mode":0, "replace-mode":0,
                       "text-marc":1}
            aleph_record = xmlmarc2textmarc.create_marc_record(record,
                                                                  sysno,
                                                                  options)
            aleph_marc_output += aleph_record

        return aleph_marc_output
示例#7
0
                         (len(match_results[0]), ))
        sys.stderr.write("\n Matched records     : %d" %
                         (len(match_results[1]), ))
        sys.stderr.write("\n Ambiguous records   : %d" %
                         (len(match_results[2]), ))
        sys.stderr.write("\n Fuzzy records       : %d\n" %
                         (len(match_results[3]), ))
        sys.stderr.write("=" * 35)
        sys.stderr.write("\n Total records       : %d\n" % (len(records), ))

    if not noprocess:
        options = {'text-marc': 1, 'aleph-marc': 0}
        for record, results in recs_out:
            if textmarc_output:
                # FIXME: textmarc output does not print matching results
                sysno = get_sysno_from_record(record, options)
                print create_marc_record(record, sysno, options)
            else:
                print results
                print record_xml_output(record)

    if batch_output:
        i = 0
        options = {'text-marc': 1, 'aleph-marc': 0}
        outputs = ['new', 'matched', 'ambiguous', 'fuzzy']
        for result in match_results:
            filename = "%s.%s" % (batch_output, outputs[i])
            file_fd = open(filename, "w")
            for record, results in result:
                out = []
                if textmarc_output:
示例#8
0
    if verbose:
        sys.stderr.write("\n\n Bibmatch report\n")
        sys.stderr.write("=" * 35)
        sys.stderr.write("\n New records         : %d" % len(match_results[0]))
        sys.stderr.write("\n Matched records     : %d" % len(match_results[1]))
        sys.stderr.write("\n Ambiguous records   : %d" % len(match_results[2]))
        sys.stderr.write("\n Fuzzy records       : %d\n" % len(match_results[3]))
        sys.stderr.write("=" * 35)
        sys.stderr.write("\n Total records       : %d\n" % len(records))

    if not noprocess:
        options = {'text-marc':1, 'aleph-marc':0}
        for record in recs_out:
            if textmarc_output:
                sysno = get_sysno_from_record(record[0], options)
                print create_marc_record(record[0], sysno, options)
            else:
                print record[3]
                print record_xml_output(record[0])

    if batch_output:
        i = 0
        options = {'text-marc':1, 'aleph-marc':0}
        for result in match_results:
            filename = "%s.%i" % (batch_output, i)
            file_fd = open(filename,"w")
            for record in result:
                out = ""
                if textmarc_output:
                    sysno = get_sysno_from_record(record[0], options)