diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-10 15:59:24 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-10 15:59:24 +0100 |
| commit | e8ce7876c5869522f982073d70c3ee7be179e1f9 (patch) | |
| tree | 367d30870781187f4f78eb074cb7cb0b632aa0c7 /util.py | |
| parent | c412e5f0f8b71d137e4f18f8a8c7361e15c8f500 (diff) | |
citation coverage reports
Diffstat (limited to 'util.py')
| -rw-r--r-- | util.py | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -87,6 +87,9 @@ def write_report(fn, title=None, keys=None, rows=[]): f.write("</html>") print("{} {}".format(fn, count)) +def percent(m, n): + return round(n / m * 100) + class NameLine(object): def __init__(self, s): self.s = s.strip() @@ -102,9 +105,12 @@ class BoldLine(object): class LinkLine(object): def __init__(self, href, txt): self.href = href - self.txt = txt.strip + self.txt = txt.strip() def __str__(self): - return '<a href="{}">{}</a>'.format(self.href, self.txt) + if self.href: + return '<a href="{}">{}</a>'.format(self.href, self.txt) + else: + return '<span class="gray">{}</a>'.format(self.txt) def write_table(f, keys, rows): count = 0 @@ -145,6 +151,13 @@ class DbPaper(object): @property def authors(self): return [ (author['ids'][0] if len(author['ids']) else '', author['name']) for author in self.data['authors'] ] + @property + def pdf_link(self): + if self.data['s2PdfUrl']: + return self.data['s2PdfUrl'] + if len(self.data['pdfUrls']): + return self.data['pdfUrls'][0] + return None def record(self): return [ self.paper_id, self.title, self.journal, self.year ] @@ -173,6 +186,9 @@ class RawPaper(object): @property def authors(self): return [ (author[0]['ids'][0] if len(author[0]['ids']) else '', author[0]['name']) for author in self.data['authors'] ] + @property + def pdf_link(self): + return self.data['primaryPaperLink'] or None def record(self): return [ self.paper_id, self.title, self.journal, self.year ] |
