def run(self): """ Run the RPCitation to rebuild index """ if not self._checkparam(): return None self.started = datetime.now() logger.info('Start RPCitation Script (R-Index citation)') icitation = ICitation(hosts=self.options.source_index) cite_total = icitation.count_citation() logger.info('Total of itens that will be re-index on ``%s``: %d' % (self.options.target_index, cite_total)) ricitation = ICitation(hosts=self.options.target_index) with ProgressBar(maxval=cite_total) as progress: for index, cite in enumerate(icitation.get_all()): ricitation.index_citation(self._get_meta(cite)) progress.update(index) self.finished = datetime.now() logger.info("Total processing time: %s sec." % self._duration())
def run(self): self.started = datetime.now() if not self._checkparam(): return None logger.info('Start Count Citation Script') icitation = ICitation(hosts=self.options.list_hosts) total_citation = icitation.count_citation() logger.info('Total of article in ES Citation: %s' % total_citation) #if identifiers dont exists create and read to get all identifiers if os.path.exists('identifiers.txt'): fp = open('identifiers.txt', 'r') es_idents = fp.readlines() else: self._file_identifiers('identifiers.txt', icitation.get_identifiers()) fp = open('identifiers.txt', 'r') es_idents = csv.reader(fp, delimiter='|', quotechar='"') #create a csv file with result f = open(self.options.output_file, 'ab') writer = csv.writer(f, delimiter='|', quotechar='"') count = 0 #loop all identifiers from ES for row in es_idents: ident = row.split('|')[0] response = self._fetch_data('http://citedby.scielo.org/api/v1/pid/?q=%s' % ident) if response.status_code == 200: citation = json.loads(response.text) #add in csv file only articles with citations if len(citation['cited_by']) > 0: writer.writerow([ident, str(len(citation['cited_by']))]) count +=1 writer.writerow(['Total of articles with current citation', str(count)]) f.close() self.finished = datetime.now() logger.info("Total processing time: %s sec." % self._duration())
def main(): usage = """\ %prog this script get all identifiers and save it on 'identifiers.txt' """ parser = optparse.OptionParser(textwrap.dedent(usage), version="%prog 0.1 - beta") parser.add_option( "-l", "--list_hosts", action="store", help="list of ES hosts, Ex.: esa.scielo.org esb.scielo.org,\ default is localhost", ) options, args = parser.parse_args(sys.argv) icitation = ICitation(hosts=options.list_hosts) total = icitation.count_citation() print "Total of article in ES Citation: %s" % total print "Get identifiers from ES Index Citation...this will take a while!" # ('acronym of collection', SciELO PID) es_idents = icitation.get_identifiers() fp = open("identifiers.txt", "a") writer = csv.writer(fp, delimiter="|", quotechar='"') for ident in es_idents: writer.writerow([ident[1], ident[0]]) fp.close()
def main(): usage = """\ %prog this script get all identifiers and save it on 'identifiers.txt' """ parser = optparse.OptionParser(textwrap.dedent(usage), version="%prog 0.1 - beta") parser.add_option( '-l', '--list_hosts', action="store", help='list of ES hosts, Ex.: esa.scielo.org esb.scielo.org,\ default is localhost') options, args = parser.parse_args(sys.argv) icitation = ICitation(hosts=options.list_hosts) total = icitation.count_citation() print 'Total of article in ES Citation: %s' % total print 'Get identifiers from ES Index Citation...this will take a while!' #('acronym of collection', SciELO PID) es_idents = icitation.get_identifiers() fp = open('identifiers.txt', 'a') writer = csv.writer(fp, delimiter='|', quotechar='"') for ident in es_idents: writer.writerow([ident[1], ident[0]]) fp.close()