Esempio n. 1
0
def cb_submit_bibupload(bibcatalog_system=None, records=None):
    if records:
        references_xml = print_records(records)

        # Save new record to file
        temp_fd, temp_path = mkstemp(prefix=CFG_REFEXTRACT_FILENAME, dir=CFG_TMPSHAREDDIR)
        temp_file = os.fdopen(temp_fd, "w")
        temp_file.write(references_xml)
        temp_file.close()

        # Update record
        task_low_level_submission("bibupload", "refextract", "-c", temp_path)
Esempio n. 2
0
def cb_submit_bibupload(bibcatalog_system=None, records=None):
    if records:
        references_xml = print_records(records)

        # Save new record to file
        temp_fd, temp_path = mkstemp(prefix=CFG_REFEXTRACT_FILENAME,
                                     dir=CFG_TMPSHAREDDIR)
        temp_file = os.fdopen(temp_fd, 'w')
        temp_file.write(references_xml)
        temp_file.close()

        # Update record
        task_low_level_submission('bibupload', 'refextract', '-c', temp_path)
Esempio n. 3
0
def write_records(config, records):
    """Write marcxml to file

    * Output xml header
    * Output collection opening tag
    * Output xml for each record
    * Output collection closing tag
    """
    if config.xmlfile:
        out = open(config.xmlfile, 'w')
    else:
        out = sys.stdout

    xml = print_records(records)

    try:
        print >> out, xml
        out.flush()
    finally:
        if config.xmlfile:
            out.close()
Esempio n. 4
0
def write_records(config, records):
    """Write marcxml to file

    * Output xml header
    * Output collection opening tag
    * Output xml for each record
    * Output collection closing tag
    """
    if config.xmlfile:
        out = open(config.xmlfile, 'w')
    else:
        out = sys.stdout

    xml = print_records(records)

    try:
        print >>out, xml
        out.flush()
    finally:
        if config.xmlfile:
            out.close()
Esempio n. 5
0
def write_references(config, records):
    """Write in marcxml"""
    if config.xmlfile:
        ofilehdl = open(config.xmlfile, 'w')
    else:
        ofilehdl = sys.stdout

    if config.xmlfile:
        for rec in records:
            for subfield in rec.find_subfields('999C5m'):
                if len(subfield.value) > 2048:
                    subfield.value = subfield.value[:2048]

    try:
        xml = print_records(records)
        print >>ofilehdl, xml
        ofilehdl.flush()
    except IOError, err:
        write_message("%s\n%s\n" % (config.xmlfile, err),
                          sys.stderr, verbose=0)
        halt(err=IOError, msg="Error: Unable to write to '%s'"
                 % config.xmlfile, exit_code=1)
Esempio n. 6
0
def write_references(config, records):
    """Write in marcxml"""
    if config.xmlfile:
        ofilehdl = open(config.xmlfile, 'w')
    else:
        ofilehdl = sys.stdout

    if config.xmlfile:
        for rec in records:
            for subfield in rec.find_subfields('999C5m'):
                if len(subfield.value) > 2048:
                    subfield.value = subfield.value[:2048]

    try:
        xml = print_records(records)
        print >> ofilehdl, xml
        ofilehdl.flush()
    except IOError, err:
        write_message("%s\n%s\n" % (config.xmlfile, err),
                      sys.stderr,
                      verbose=0)
        halt(err=IOError,
             msg="Error: Unable to write to '%s'" % config.xmlfile,
             exit_code=1)