publist

managing my list of publications, talks, reviews
git clone https://a3nm.net/git/publist/
Log | Files | Refs | README | LICENSE

makereviews.py (3657B)


      1 #!/usr/bin/python3
      2 # arguments: maketex.py LANGUAGE [FORMAT [PUBLICATION [FOLDER]]]
      3 # LANGUAGE is "en" (default) or "fr"
      4 # FORMAT is "tex" (default) or "bib"
      5 # PUBLICATION is the id of the publication to compile, or:
      6 # - "all" for all publications
      7 # - "cv" for all CV publications: all publications that are main, reviewed, not
      8 #   hidden (default)
      9 # FOLDER is where to find "publis" "venues" "authors", default is script dir
     10 
     11 from parserec import parse, isurlrel, absurl, getyear, endswithpunct, mkvenuename
     12 from make_talks_html import makevenue2
     13 from maketex import venuetotex
     14 import os
     15 import sys
     16 
     17 if len(sys.argv) > 5:
     18     print("too many arguments", file=sys.stderr)
     19     sys.exit(1)
     20 
     21 lang = "en"
     22 try:
     23     lang = sys.argv[1]
     24 except IndexError:
     25     pass
     26 
     27 fmt = 'tex'
     28 try:
     29     fmt = sys.argv[2]
     30 except IndexError:
     31     pass
     32 
     33 thepubli = None
     34 try:
     35     thepubli = sys.argv[3]
     36 except IndexError:
     37     pass
     38 
     39 # http://stackoverflow.com/a/1432949
     40 abspath = os.path.abspath(__file__)
     41 dname = os.path.dirname(abspath)
     42 
     43 folder = dname
     44 try:
     45     folder = sys.argv[4]
     46 except IndexError:
     47     pass
     48 os.chdir(dname)
     49 
     50 venuesz = dict((x['id'], x) for x in parse('venues'))
     51 
     52 def getmisc(review):
     53     misck = 'misc' + lang 
     54     if misck in review.keys():
     55         return " (%s)" % review[misck]
     56     return ""
     57 
     58 def tex_emifjournal(venuename, venue):
     59     if venue['type'] == 'journal':
     60         return "\\emph{%s}" % venuename
     61     return venuename
     62 
     63 def reviewtotex(x):
     64     global venuesz
     65     review, venue = x
     66     venuename = mkvenuename(venue, venuesz, short=True)
     67     ans = venuetotex(tex_emifjournal(venuename, venue), venue['url'], None)
     68     return ans + getmisc(review)
     69 
     70 def reviewtohtml(lang, x):
     71     global venuesz
     72     review, venue = x
     73     venuename = mkvenuename(venue, venuesz)
     74     ans = makevenue2(venuename, lang, venue['type'] if 'type' in venue.keys()
     75             else '', venue['url'], "")
     76     return ans + getmisc(review)
     77 
     78 venues = {}
     79 
     80 pc = []
     81 journal_misc = []
     82 other_misc = []
     83 
     84 term = {
     85         'en':
     86         {
     87             'pc': "PC member",
     88             'spc': "Senior PC member",
     89             'pc_demos': "(demos)",
     90             'misc': "Misc reviews",
     91         },
     92         'fr':
     93         {
     94             'pc': "Comité de programme",
     95             'spc': "Membre senior du comité de programme",
     96             'pc_demos': "(démonstrations)",
     97             'misc': "Relectures diverses",
     98         },
     99         }
    100 
    101 for review in parse('reviews'):
    102     venue = venuesz[review['id']]
    103     if 'main' in review.keys() and review['main'] == 'no':
    104         continue # skip non-main venues
    105     if 'oa' in venue.keys() and venue['oa'] == 'no':
    106         continue # don't boast about reviewing for non-OA venues
    107     if review['role'] in ['pc', 'spc']:
    108         pc.append((review, venue))
    109     elif review['role'] == 'pc_demos':
    110         other_misc.append((review, venue)) # demo PC counted as misc for simplicity
    111     else:
    112         assert(review['role'] == 'misc')
    113         if venue['type'] == 'journal':
    114             journal_misc.append((review, venue))
    115         else:
    116             assert(venue['type'] in ['conference', 'workshop'])
    117             other_misc.append((review, venue))
    118 
    119 if fmt == 'tex':
    120     print("\\cvitem{%s}{%s}" % (term[lang]['pc'],
    121         ", ".join(reviewtotex(x) for x in pc)))
    122     print("\\cvitem{%s}{%s}" % (term[lang]['misc'],
    123         ", ".join(reviewtotex(x) for x in journal_misc + other_misc)))
    124 else:
    125     assert(fmt == 'html')
    126     print("<dt>%s</dt><dd>%s</dd>" % (term[lang]['pc'],
    127         ",\n".join(reviewtohtml(lang, x) for x in pc)))
    128     print("<dt>%s</dt><dd>%s</dd>" % (term[lang]['misc'],
    129         ",\n".join(reviewtohtml(lang, x) for x in journal_misc + other_misc)))
    130