def main(): verbose = '-v' in sys.argv recids = perform_request_search(p='-035:spirestex -035:inspiretex', cc='HEP') print "Found %s records to assign texkeys" % len(recids) processed = [] to_process = [] for count, recid in enumerate(recids): if count % 300 == 0: print 'done %s of %s' % (count, len(recids)) if verbose: print "processing ", recid # Check that the record does not have already a texkey has_texkey = False recstruct = get_record(recid) for instance in record_get_field_instances(recstruct, tag="035", ind1="", ind2=""): try: provenance = field_get_subfield_values(instance, "9")[0] except IndexError: provenance = "" try: value = field_get_subfield_values(instance, "z")[0] except IndexError: value = "" provenances = ["SPIRESTeX", "INSPIRETeX"] if provenance in provenances and value: has_texkey = True print "INFO: Record %s has already texkey %s" % (recid, value) if not has_texkey: TexKeySeq = TexkeySeq() new_texkey = "" try: new_texkey = TexKeySeq.next_value(recid) except TexkeyNoAuthorError: print "WARNING: Record %s has no first author or collaboration" % recid continue xml = create_xml(recid, new_texkey) processed.append(recid) to_process.append(xml) if len(to_process) == 500: process_chunk(to_process) to_process = [] if to_process: process_chunk(to_process) # Finally, index all the records processed if processed: submit_bibindex_task(processed)
def test_get_next_texkey3(self): """ Generate the third texkey """ texkey_seq = TexkeySeq() self.texkey3 = texkey_seq.next_value(xml_record=get_sample_texkey(2)) self.assertEqual(self.texkey3[:-3], 'ATLAS:2012')
def test_get_next_texkey2(self): """ Generate the second texkey """ texkey_seq = TexkeySeq() self.texkey2 = texkey_seq.next_value(xml_record=get_sample_texkey(1)) self.assertEqual(self.texkey2[:-3], 'Broekhoven-Fiene:2012')
def test_get_next_texkey1(self): """ Generate the first texkey """ texkey_seq = TexkeySeq() self.texkey1 = texkey_seq.next_value(xml_record=get_sample_texkey(0)) self.assertEqual(self.texkey1[:-3], 'Boyle:2012')