Пример #1
0
def create_vas_from_doclist():
    '''
    Processes the document list and creates a new minimal virtual author
    for each author in each record.
    '''
    bconfig.LOGGER.log(
        25, "Creating minimal virtual authors for "
        "all loaded docs")

    for docs in [row for row in dat.DOC_LIST]:
        for author_id in docs['authornameids']:
            author_name = [
                an['name'] for an in dat.AUTHOR_NAMES if an['id'] == author_id
            ]
            refrecs = [
                ref[1] for ref in docs['authornameid_bibrefrec']
                if ref[0] == author_id
            ]
            refrec = -1

            if len(refrecs) > 1:
                print "Several bibrefs on one paper?! How?"
                refrec = refrecs[0]
            elif refrecs:
                refrec = refrecs[0]

            add_minimum_virtualauthor(author_id, author_name[0],
                                      docs['bibrecid'], 0, [], refrec)
    def create_vas_from_specific_doclist(bibrec_ids):
        '''
        Processes the document list and creates a new minimal virtual author
        for each author in each record specified in the given list.

        @param bibrec_ids: Record IDs to concern in this update
        @type bibrec_ids: list of int
        '''
        num_docs = len([row for row in dat.DOC_LIST
                     if row['bibrecid'] in bibrec_ids])

        bconfig.LOGGER.log(25, "Creating minimal virtual authors for "
                                "all loaded docs (%s)"
                                % (num_docs))

        for docs in [row for row in dat.DOC_LIST
                     if row['bibrecid'] in bibrec_ids]:
            for author_id in docs['authornameids']:
                author_name = [an['name'] for an in dat.AUTHOR_NAMES
                               if an['id'] == author_id]
                refrecs = [ref[1] for ref in docs['authornameid_bibrefrec']
                           if ref[0] == author_id]
                refrec = -1

                if len(refrecs) > 1:
                    refrec = refrecs[0]
                elif refrecs:
                    refrec = refrecs[0]

                if refrec and author_name:
                    add_minimum_virtualauthor(author_id, author_name[0],
                                              docs['bibrecid'], 0, [], refrec)
                elif author_name:
                    add_minimum_virtualauthor(author_id, author_name[0],
                                              docs['bibrecid'], 0, [])
    def create_vas_from_specific_doclist(bibrec_ids):
        '''
        Processes the document list and creates a new minimal virtual author
        for each author in each record specified in the given list.

        @param bibrec_ids: Record IDs to concern in this update
        @type bibrec_ids: list of int
        '''
        num_docs = len(
            [row for row in dat.DOC_LIST if row['bibrecid'] in bibrec_ids])

        bconfig.LOGGER.log(
            25, "Creating minimal virtual authors for "
            "all loaded docs (%s)" % (num_docs))

        for docs in [
                row for row in dat.DOC_LIST if row['bibrecid'] in bibrec_ids
        ]:
            for author_id in docs['authornameids']:
                author_name = [
                    an['name'] for an in dat.AUTHOR_NAMES
                    if an['id'] == author_id
                ]
                refrecs = [
                    ref[1] for ref in docs['authornameid_bibrefrec']
                    if ref[0] == author_id
                ]
                refrec = -1

                if len(refrecs) > 1:
                    print "SCREEEEEEWWWWWWED!!! Several bibrefs on one paper?!"
                    refrec = refrecs[0]
                elif refrecs:
                    refrec = refrecs[0]

                if refrec and author_name:
                    add_minimum_virtualauthor(author_id, author_name[0],
                                              docs['bibrecid'], 0, [], refrec)
                elif author_name:
                    add_minimum_virtualauthor(author_id, author_name[0],
                                              docs['bibrecid'], 0, [])
def create_vas_from_doclist():
    '''
    Processes the document list and creates a new minimal virtual author
    for each author in each record.
    '''
    bconfig.LOGGER.log(25, "Creating minimal virtual authors for "
                            "all loaded docs")

    for docs in [row for row in dat.DOC_LIST]:
        for author_id in docs['authornameids']:
            author_name = [an['name'] for an in dat.AUTHOR_NAMES
                           if an['id'] == author_id]
            refrecs = [ref[1] for ref in docs['authornameid_bibrefrec']
                       if ref[0] == author_id]
            refrec = -1

            if len(refrecs) > 1:
                print "Several bibrefs on one paper?! How?"
                refrec = refrecs[0]
            elif refrecs:
                refrec = refrecs[0]

            add_minimum_virtualauthor(author_id, author_name[0],
                                          docs['bibrecid'], 0, [], refrec)