def find_and_process_updates(process_initials):
    """
    Finds and processes not updated virtualauthors (which are identified by
    the 'updated' tag) and delivers the ID of this virtualauthor to the
    function responsible for assigning the virtualauthor to a realauthor.

    @param process_initials: If names with initials only shall be
        processed or not
    @type process_initials: boolean
    """
    if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
        init_va_process_queue()

    while True:
        va_id = -1

        if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
            bconfig.LOGGER.debug("Empty Queue. Job finished. Nothing to do.")
            break
        else:
            va_id = dat.VIRTUALAUTHOR_PROCESS_QUEUE.get()

        va_name = bibauthorid_virtualauthor_utils.get_virtualauthor_records(va_id, tag="orig_name_string")[0]["value"]

        if not process_initials:
            if bibauthorid_utils.split_name_parts(va_name)[2]:
                (bibauthorid_virtualauthor_utils.delete_virtualauthor_record(va_id, "updated"))
                bconfig.LOGGER.log(25, "|> Inserting VA:" + " %s Orig. name: %s" % (va_id, va_name))
                add_virtualauthor(va_id)
        else:
            (bibauthorid_virtualauthor_utils.delete_virtualauthor_record(va_id, "updated"))
            bconfig.LOGGER.log(25, "|> Inserting VA: %s Orig. name: %s" % (va_id, va_name))
            add_virtualauthor(va_id)
def find_and_process_orphans(iterations=1):
    """
    Finds and processes orphaned virtual authors.

    @param iterations: Number of rounds to do this processing
    @type iterations: int
    """
    multi_attach = False
    #    processed_orphans = set()

    for iteration in xrange(iterations):
        if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
            init_va_process_queue(mode="orphaned")

        while True:
            va_id = -1

            if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
                bconfig.LOGGER.debug("Empty Queue. Job finished." " Nothing to do.")
                break
            else:
                va_id = dat.VIRTUALAUTHOR_PROCESS_QUEUE.get()

            #            if va_id not in dat.PROCESSED_ORPHANS:
            va_name = bibauthorid_virtualauthor_utils.get_virtualauthor_records(va_id, tag="orig_name_string")[0][
                "value"
            ]
            bconfig.LOGGER.log(25, "|> Inserting orphaned VA: %s Name: %s" % (va_id, va_name))

            if (bconfig.ATTACH_VA_TO_MULTIPLE_RAS) and (iteration == iterations - 1):
                multi_attach = True

            add_virtualauthor(va_id, multi_attach)
def find_and_process_updates(process_initials):
    '''
    Finds and processes not updated virtualauthors (which are identified by
    the 'updated' tag) and delivers the ID of this virtualauthor to the
    function responsible for assigning the virtualauthor to a realauthor.

    @param process_initials: If names with initials only shall be
        processed or not
    @type process_initials: boolean
    '''
    if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
        init_va_process_queue()

    while True:
        va_id = -1

        if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
            bconfig.LOGGER.debug("Empty Queue. Job finished. Nothing to do.")
            break
        else:
            va_id = dat.VIRTUALAUTHOR_PROCESS_QUEUE.get()

        va_name = (bibauthorid_virtualauthor_utils.
                   get_virtualauthor_records(va_id,
                                         tag='orig_name_string')[0]['value'])

        if not process_initials:
            if bibauthorid_utils.split_name_parts(va_name)[2]:
                (bibauthorid_virtualauthor_utils.
                 delete_virtualauthor_record(va_id, 'updated'))
                bconfig.LOGGER.log(25, "|> Inserting VA:"
                      + " %s Orig. name: %s" % (va_id, va_name))
                add_virtualauthor(va_id)
        else:
            (bibauthorid_virtualauthor_utils.
             delete_virtualauthor_record(va_id, 'updated'))
            bconfig.LOGGER.log(25, "|> Inserting VA: %s Orig. name: %s"
                          % (va_id, va_name))
            add_virtualauthor(va_id)
Example #4
0
def find_and_process_orphans(iterations=1):
    '''
    Finds and processes orphaned virtual authors.

    @param iterations: Number of rounds to do this processing
    @type iterations: int
    '''
    multi_attach = False
    #    processed_orphans = set()

    for iteration in xrange(iterations):
        if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
            init_va_process_queue(mode="orphaned")

        while True:
            va_id = -1

            if dat.VIRTUALAUTHOR_PROCESS_QUEUE.empty():
                bconfig.LOGGER.debug("Empty Queue. Job finished."
                                     " Nothing to do.")
                break
            else:
                va_id = dat.VIRTUALAUTHOR_PROCESS_QUEUE.get()


#            if va_id not in dat.PROCESSED_ORPHANS:
            va_name = (
                bibauthorid_virtualauthor_utils.get_virtualauthor_records(
                    va_id, tag='orig_name_string')[0]['value'])
            bconfig.LOGGER.log(
                25, "|> Inserting orphaned VA: %s Name: %s" % (va_id, va_name))

            if ((bconfig.ATTACH_VA_TO_MULTIPLE_RAS)
                    and (iteration == iterations - 1)):
                multi_attach = True

            add_virtualauthor(va_id, multi_attach)