Browse Source

Added keywords and handling for collaboration papers

Andreas Kopmann 6 years ago
parent
commit
aaa1576177
3 changed files with 180 additions and 11 deletions
  1. 17 10
      ak_scopus.py
  2. 19 1
      ak_wordpress.py
  3. 144 0
      etc/config_ufo_kit_edu_ipe.py

+ 17 - 10
ak_scopus.py

@@ -3,6 +3,7 @@
 
 import requests
 import json
+from pprint import pprint
 
 from config import *
 
@@ -114,7 +115,9 @@ def get_scopus_data(SCOPUS_ID):
     url = ("http://api.elsevier.com/content/abstract/scopus_id/"
            + SCOPUS_ID
            + "?field=article-number,title,publicationName,volume,issueIdentifier,"
-           + "prism:pageRange,coverDate,article-number,eid,doi,citedby-count,prism:aggregationType,url,identifier,description,authkeywords,authors,prism:issn")
+           + "prism:pageRange,coverDate,article-number,eid,doi,citedby-count,"
+	   + "prism:aggregationType,url,identifier,description,authkeywords,"
+	   + "authors,prism:issn,idxterms")
     #print url
     resp = requests.get(url,
             headers={'Accept':'application/json',
@@ -148,19 +151,23 @@ def get_scopus_refs(EID):
         resp = requests.get(url,headers={'Accept':'application/json','X-ELS-APIKey':MY_API_KEY})
 
         results = resp.json()
-        #print json.dumps(results,sort_keys=True,indent=4, separators=(',', ': '))
+        #pprint (json.dumps(results,sort_keys=True,indent=4, separators=(',', ': ')))
 
-        if (n==0):
-            n = int(results['search-results']['opensearch:totalResults'])
-            #print "Current number citations in scopus = %d" % n
-            npubstoget = n
+        try:
+           if (n==0):
+               n = int(results['search-results']['opensearch:totalResults'])
+               #print "Current number citations in scopus = %d" % n
+               npubstoget = n
 
-        if (n>0):
-                publist += results['search-results']['entry']
+           if (n>0):
+               publist += results['search-results']['entry']
 
-        npubstoget = npubstoget - count
-        start += count
+           npubstoget = npubstoget - count
+           start += count
 
+        except:
+	   print "Error:"
+	   pprint (json.dumps(results,sort_keys=True,indent=4, separators=(',', ': ')))
 
     return publist
 

+ 19 - 1
ak_wordpress.py

@@ -6,6 +6,7 @@
 
 from datetime import datetime
 import json
+from pprint import pprint
 
 from wordpress_xmlrpc import Client
 from wordpress_xmlrpc import WordPressPost, WordPressComment
@@ -116,17 +117,34 @@ def wordpress_post_by_scopus(data, category = []):
 
     post.id = wp.call(NewPost(post)) # Creates a new post and returns the id!
 
+    try:
+        taglist = []
+        for tag in data['abstracts-retrieval-response']['idxterms']['mainterm']:
+	    #print tag['$'],type(tag['$'])
+            taglist.append(tag['$'])
+    except:
+        pass
+
+    print "Keywords:"
+    print taglist
 
     if category == '':
         catlist = ['Publications']
     else:
         catlist = ['Publications'] + category
     post.terms_names = {
+	    'post_tag': taglist,
             'category': catlist # defined in WP + python script
         }
 
     # whoops, I forgot to publish it!
-    post.post_status = 'publish' # alternative is draft here !
+    #post.post_status = 'publish' # alternative is draft here !
+    if (len(authors) > 25):
+        post.post_status = 'draft' # alternative is draft here !
+        print "Too many authors %d - might be a collaboration paper!?" % (len(authors))
+    else:
+        post.post_status = 'publish' # alternative is draft here !
+
     post.comment_status = 'closed' # allow comments - may be only for scopus
     wp.call(EditPost(post.id, post))# Update the before created post
 

+ 144 - 0
etc/config_ufo_kit_edu_ipe.py

@@ -0,0 +1,144 @@
+""" Scopus script's configration
+    
+    *A Kopmann, 12.4.17*
+
+Configuration for the IPE setup at ufo.kit.edu
+
+"""
+
+# Local publication database
+
+db_host = 'localhost'
+db_user = 'scopus'
+db_pw = '$scopus$'
+db_name = 'scopus_ipe'
+
+
+# Access to Wordpress installation
+
+wp_api_url = "https://ufo.kit.edu/ipe/xmlrpc.php"
+""" Access to the Wordpress installation """
+wp_user = "scopus"
+wp_password = "$scopus$"
+
+
+# Reporting
+
+log_file = "/root/scopus-ipe/log/scopus-publications-ufo-kit-edu-ipe.log"
+""" Logfile name for reporting """
+
+
+# Scopus query definition
+
+MY_API_KEY = "14d431d052c2caf5e9c4b1ab7de7463d"
+""" Scopus access key (Andreas Kopmann) """
+
+
+# Scopus author IDs
+
+# KIT, PDV
+andreasKopmann = "35313939900"
+ak2 = "57193311016"
+surenChilingaryan = "15076530600"
+matthiasVogelgesang = "35303862100"
+timoDritschler = "56473578500"
+#andreiShkarin = "56950893700"
+nicholasTanJerome = ""
+#tillBergmann = "35308595100"
+armenBeglarian = "55343303900"
+petraRohr = "40561503300"
+norbertKunka = "35276889200"
+horstDemattio = "6506285395"
+heinzFrankrone = ""
+danielKompalla = ""
+
+
+# KIT, EPS
+micheleCaselle = "57194376511"
+mc2 = "57194376512"
+#urosStevanovic = "55557712600"
+lorenzoRota = "56473442500"
+matthiasBalzer = "35519411500"
+matthiasKleifges = "6602072426"
+luisArdila = "" 
+nickKarcher = "" 
+alexanderMenshikov = "7003298761"
+denisTcherniakhovski = "6508308928"
+thomasSchuh = ""
+oliverSander = "22986354000"
+
+
+# KIT, MSA
+thomasKuehner = "24776279000"
+saschaWuestling = "23480623800"
+heikoBouquet = ""
+birgitBurger = ""
+andreasEbersold = "" 
+larsEisenblaetter = "57094104200"
+juliusHartmann = ""
+djornKarnick = "37081197400"
+marcSchneider = "55649571035"
+ms2 = "55649571037"
+ms3 = "55649571036"
+ms4 = "55649571041"
+oliverKroemer = "8520193800"
+klausPetry = "7004446817"
+
+
+# KIT, ADL
+ivanPeric = "9043482900"
+felixEhrler = "56674370500"
+robertoBlanco = "56927736400"
+alenaWeber = ""
+
+
+# KIT, AVT
+thomasBlank = "56819218800"
+simonBischof = "" 
+anBao = "57192082222"
+helgeWurst = "" 
+
+# KIT, SWM
+nicoleRuiter = "6507953977"
+torstenHopp = "24469880700"
+michaelZapf = "19640815400"
+
+
+# KIT, IPE
+marcWeber = "56654729000"
+mw2 = "56603987800"
+mw3 = "7404138824"
+
+
+
+# Definition of workgroups for automatic Scopus publication retrieval
+
+sc_start = 2014
+
+ipe_pdv = [andreasKopmann,ak2,surenChilingaryan,matthiasVogelgesang,timoDritschler,armenBeglarian,horstDemattio,petraRohr,norbertKunka]
+ipe_eps = [matthiasBalzer,lorenzoRota,micheleCaselle,mc2,matthiasKleifges,alexanderMenshikov,denisTcherniakhovski,oliverSander]
+ipe_msa = [thomasKuehner,saschaWuestling,larsEisenblaetter,djornKarnick,marcSchneider,ms2,ms3,ms4,oliverKroemer,klausPetry]
+ipe_avt = [thomasBlank]
+ipe_adl = [ivanPeric,felixEhrler,robertoBlanco]
+ipe_swm = [nicoleRuiter,torstenHopp,michaelZapf] 
+
+
+sc_workgroups = [
+{'name':"Data processing",'authors':ipe_pdv},
+{'name':"Embedded parallel systems",'authors':ipe_eps},
+{'name':"Microprocessor systems and analog instrumentation",'authors':ipe_msa},
+{'name':"Electronic packaging and interconnects",'authors':ipe_avt},
+{'name':"ASIC- and detector laboratory",'authors':ipe_adl},
+{'name':"Software methods",'authors':ipe_swm}
+]
+""" Definition of the workgroups
+    
+    Each workgroup is defined by a list of Scopus ID's and the
+    name of the category to be used in Wordpress. The category
+    for a new workgroup has to be created in Wordpress before
+    adding publications
+    """
+
+
+
+