|
@@ -1,17 +1,37 @@
|
|
|
-# Get new publications
|
|
|
-# Publication and citations retrieval
|
|
|
-# A. Kopmann, 6.2.17 (ak)
|
|
|
-#
|
|
|
-# Scope:
|
|
|
-# Publications are once added to wordpressas a post or comment.
|
|
|
-# Afterwards scopus will not change or modify anything any more !!!
|
|
|
-# Update is completely in the resonsibility of the ufo users
|
|
|
-#
|
|
|
-
|
|
|
-# Todo:
|
|
|
-# - add mail to author button
|
|
|
-# - save full scopus data in the database
|
|
|
-#
|
|
|
+""" Publication and citations retrieval
|
|
|
+
|
|
|
+*A. Kopmann, 6.2.17 (ak)*
|
|
|
+
|
|
|
+
|
|
|
+Scope:
|
|
|
+ Publications are once added to wordpressas a post or comment.
|
|
|
+ Afterwards scopus will not change or modify anything any more.
|
|
|
+ Update is completely in the resonsibility of the ufo users.
|
|
|
+
|
|
|
+The operation of the script splits in four phases:
|
|
|
+ - Read all publications for one or more author groups
|
|
|
+ The groups are all defined in the configuration file
|
|
|
+ The publications are stored in a local cache database
|
|
|
+ - For all new publication a post in Wordpress is created.
|
|
|
+ The post is added to the catogeries accouring to the matching
|
|
|
+ author groups
|
|
|
+ - For each publication the citations are requested and stored
|
|
|
+ in the local cache database as well
|
|
|
+ - For each new citation a Wordpress comment is created.
|
|
|
+
|
|
|
+
|
|
|
+Todo:
|
|
|
+ - add mail to author button
|
|
|
+ - save full scopus data in the database
|
|
|
+ - Add a script to save the data for all publications in the database!!!
|
|
|
+ There was some problem before?!
|
|
|
+ - Add scripts to check consistence in the database
|
|
|
+ and fix problems if detected
|
|
|
+ E.g. search for wpcommentid == 0
|
|
|
+ Check if, wp posts + comments are still availabe, display
|
|
|
+ deleted entries
|
|
|
+"""
|
|
|
+
|
|
|
|
|
|
# Configuration - Scopus
|
|
|
|
|
@@ -20,8 +40,6 @@ import requests
|
|
|
import json
|
|
|
import os.path
|
|
|
|
|
|
-#from my_scopus import MY_API_KEY
|
|
|
-#from my_scopus import ak, csa, pdv, ufo, ufo_pdv, ufo_ips, ufo_eps, ufo_apps
|
|
|
from ak_scopus import get_scopus_list, get_scopus_data, get_scopus_refs
|
|
|
|
|
|
|
|
@@ -43,8 +61,8 @@ nnewcites = 0
|
|
|
|
|
|
|
|
|
|
|
|
-# Read publications of a list of authors and store in the database
|
|
|
def update_publications(authids,authname='',scopus_opts = '',max=0):
|
|
|
+ """ Read publications of a list of authors and store in the database """
|
|
|
|
|
|
|
|
|
print "=== Update of publications for the author group: " + authname
|
|
@@ -107,8 +125,10 @@ def update_publications(authids,authname='',scopus_opts = '',max=0):
|
|
|
connection.close()
|
|
|
|
|
|
|
|
|
-# Read all citations and store in the citation table
|
|
|
def update_citations():
|
|
|
+ """ Read all citations and store in the citation table """
|
|
|
+
|
|
|
+
|
|
|
global npubs
|
|
|
|
|
|
print ""
|
|
@@ -184,8 +204,10 @@ def update_citations():
|
|
|
|
|
|
|
|
|
|
|
|
-# Create wordpress posts for all entries that have none
|
|
|
def update_wp_posts():
|
|
|
+ """ Create wordpress posts for all entries that have none """
|
|
|
+
|
|
|
+
|
|
|
global nnewpubs
|
|
|
|
|
|
print ""
|
|
@@ -253,6 +275,8 @@ def update_wp_posts():
|
|
|
|
|
|
|
|
|
def update_wp_comments():
|
|
|
+ """ Create a new comment for newly found citations """
|
|
|
+
|
|
|
global ncites
|
|
|
global nnewcites
|
|
|
|
|
@@ -311,92 +335,76 @@ def update_wp_comments():
|
|
|
connection.close()
|
|
|
|
|
|
|
|
|
-# Todo: Add a script to save the data for all publications in the database!!!
|
|
|
-# There was some problem before?!
|
|
|
-#
|
|
|
-
|
|
|
-# Todo: Add scripts to check consistence in the database
|
|
|
-# and fix problems if detected
|
|
|
-# E.g. search for wpcommentid == 0
|
|
|
-# Check if, wp posts + comments are still availabe, display
|
|
|
-# deleted entries
|
|
|
-#
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
# Main
|
|
|
|
|
|
-start = datetime.datetime.now()
|
|
|
+# Prevent sphinx from execution
|
|
|
+if __name__ == "__main__":
|
|
|
|
|
|
-print ""
|
|
|
-print "***********************************************"
|
|
|
-print "**** scopus-get-publications / " + start.strftime("%Y-%m-%d") + " *****"
|
|
|
-print "***********************************************"
|
|
|
-print ""
|
|
|
|
|
|
+ start = datetime.datetime.now()
|
|
|
|
|
|
+ print ""
|
|
|
+ print "***********************************************"
|
|
|
+ print "**** scopus-get-publications / " + start.strftime("%Y-%m-%d") + " *****"
|
|
|
+ print "***********************************************"
|
|
|
+ print ""
|
|
|
|
|
|
-# Update publaction database; search for new publications
|
|
|
-# Loop over all user groups defined in ak_scopus.py
|
|
|
|
|
|
-# Todo: Detect, if there is no access to scopus !!!
|
|
|
-#
|
|
|
|
|
|
-search_param = '(PUBYEAR AFT %d)' % (sc_start)
|
|
|
+ # Update publaction database; search for new publications
|
|
|
+ # Loop over all user groups defined in ak_scopus.py
|
|
|
|
|
|
-for wp in sc_workgroups:
|
|
|
- update_publications(wp['authors'],wp['name'],search_param)
|
|
|
+ # Todo: Detect, if there is no access to scopus !!!
|
|
|
+ #
|
|
|
|
|
|
-update_wp_posts()
|
|
|
+ search_param = '(PUBYEAR AFT %d)' % (sc_start)
|
|
|
|
|
|
-# read all citations
|
|
|
-# Todo: read only new citations?!
|
|
|
+ for wp in sc_workgroups:
|
|
|
+ update_publications(wp['authors'],wp['name'],search_param)
|
|
|
|
|
|
-update_citations()
|
|
|
+ update_wp_posts()
|
|
|
|
|
|
+ # read all citations
|
|
|
+ # Todo: read only new citations?!
|
|
|
|
|
|
-# loop over all cites and post comments to wordpress, when necessary
|
|
|
-# update database
|
|
|
+ update_citations()
|
|
|
|
|
|
-update_wp_comments()
|
|
|
-# Todo: deactivate comments for scopus posts!!!
|
|
|
|
|
|
+ # loop over all cites and post comments to wordpress, when necessary
|
|
|
+ # update database
|
|
|
|
|
|
-# Display summary
|
|
|
-end = datetime.datetime.now()
|
|
|
-print ""
|
|
|
-print "Summary: (see also logfile %s) " % log_file
|
|
|
-print "Date = " + str(start)
|
|
|
-print "NPubs = " + str(npubs)
|
|
|
-print "NNewPubs = " + str(nnewpubs)
|
|
|
-print "NCites = " + str(ncites)
|
|
|
-print "NNewCites = " + str(nnewcites)
|
|
|
-print "Runtime = " + str(end - start)
|
|
|
+ update_wp_comments()
|
|
|
+ # Todo: deactivate comments for scopus posts!!!
|
|
|
|
|
|
|
|
|
-# Write summary to log file
|
|
|
-if not os.path.isfile(log_file):
|
|
|
- print "Create logfile " + log_file
|
|
|
- # Open file and write header
|
|
|
- log = open(log_file,"w")
|
|
|
- log.write(__file__ + "\n")
|
|
|
- log.write("\n")
|
|
|
- log.write(" Date\t Time\tNPubs\tNNewP\tNCite\tNNewC\t TRun\n")
|
|
|
- log.write("------------------------------------------------------------------------------\n")
|
|
|
+ # Display summary
|
|
|
+ end = datetime.datetime.now()
|
|
|
+ print ""
|
|
|
+ print "Summary: (see also logfile %s) " % log_file
|
|
|
+ print "Date = " + str(start)
|
|
|
+ print "NPubs = " + str(npubs)
|
|
|
+ print "NNewPubs = " + str(nnewpubs)
|
|
|
+ print "NCites = " + str(ncites)
|
|
|
+ print "NNewCites = " + str(nnewcites)
|
|
|
+ print "Runtime = " + str(end - start)
|
|
|
+
|
|
|
+
|
|
|
+ # Write summary to log file
|
|
|
+ if not os.path.isfile(log_file):
|
|
|
+ print "Create logfile " + log_file
|
|
|
+ # Open file and write header
|
|
|
+ log = open(log_file,"w")
|
|
|
+ log.write(__file__ + "\n")
|
|
|
+ log.write("\n")
|
|
|
+ log.write(" Date\t Time\tNPubs\tNNewP\tNCite\tNNewC\t TRun\n")
|
|
|
+ log.write("------------------------------------------------------------------------------\n")
|
|
|
+ log.close()
|
|
|
+
|
|
|
+
|
|
|
+ log = open(log_file,"a")
|
|
|
+ log.write("%s\t%s\t%5d\t%5d\t%5d\t%5d\t%s\n" % (start.strftime("%Y-%m-%d"),
|
|
|
+ start.strftime("%H:%M:%S"),
|
|
|
+ npubs,nnewpubs,ncites,nnewcites,str(end-start)))
|
|
|
log.close()
|
|
|
|
|
|
-
|
|
|
-log = open(log_file,"a")
|
|
|
-log.write("%s\t%s\t%5d\t%5d\t%5d\t%5d\t%s\n" % (start.strftime("%Y-%m-%d"),
|
|
|
- start.strftime("%H:%M:%S"),
|
|
|
- npubs,nnewpubs,ncites,nnewcites,str(end-start)))
|
|
|
-log.close()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-# done
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ # done
|