hotfix for #164
This commit is contained in:
parent
efb91b1ff4
commit
a58f1b1d5e
@ -16,18 +16,22 @@ def command(conf, args):
|
||||
papers = list(rp.all_papers())
|
||||
|
||||
paper_count = len(papers)
|
||||
doc_count = sum([0 if p.docpath is None else 1 for p in papers])
|
||||
tag_count = len(list(rp.get_tags()))
|
||||
papers_with_tags = sum([0 if p.tags else 1 for p in papers])
|
||||
if paper_count == 0:
|
||||
ui.message('Your pubs repository is empty.')
|
||||
|
||||
ui.message(color.dye_out('Repository statistics:', 'bold'))
|
||||
ui.message('Total papers: {}, {} ({}) have a document attached'.format(
|
||||
color.dye_out('{:d}'.format(paper_count), 'bgreen'),
|
||||
color.dye_out('{:d}'.format(doc_count), 'bold'),
|
||||
'{:.0f}%'.format(100. * doc_count / paper_count),
|
||||
))
|
||||
ui.message('Total tags: {}, {} ({}) of papers have at least one tag'.format(
|
||||
color.dye_out('{:d}'.format(tag_count), 'bgreen'),
|
||||
color.dye_out('{:d}'.format(papers_with_tags), 'bold'),
|
||||
'{:.0f}%'.format(100. * papers_with_tags / paper_count),
|
||||
))
|
||||
else:
|
||||
doc_count = sum([0 if p.docpath is None else 1 for p in papers])
|
||||
tag_count = len(list(rp.get_tags()))
|
||||
papers_with_tags = sum([0 if p.tags else 1 for p in papers])
|
||||
|
||||
ui.message(color.dye_out('Repository statistics:', 'bold'))
|
||||
ui.message('Total papers: {}, {} ({}) have a document attached'.format(
|
||||
color.dye_out('{:d}'.format(paper_count), 'bgreen'),
|
||||
color.dye_out('{:d}'.format(doc_count), 'bold'),
|
||||
'{:.0f}%'.format(100. * doc_count / paper_count),
|
||||
))
|
||||
ui.message('Total tags: {}, {} ({}) of papers have at least one tag'.format(
|
||||
color.dye_out('{:d}'.format(tag_count), 'bgreen'),
|
||||
color.dye_out('{:d}'.format(papers_with_tags), 'bold'),
|
||||
'{:.0f}%'.format(100. * papers_with_tags / paper_count),
|
||||
))
|
||||
|
@ -984,6 +984,7 @@ class TestUsecase(DataCommandTestCase):
|
||||
|
||||
def test_statistics(self):
|
||||
cmds = ['pubs init',
|
||||
'pubs statistics',
|
||||
'pubs add data/pagerank.bib',
|
||||
'pubs add -d data/turing-mind-1950.pdf data/turing1950.bib',
|
||||
'pubs add data/martius.bib',
|
||||
@ -993,6 +994,8 @@ class TestUsecase(DataCommandTestCase):
|
||||
'pubs statistics',
|
||||
]
|
||||
out = self.execute_cmds(cmds)
|
||||
lines = out[1].splitlines()
|
||||
self.assertEqual(lines[0], 'Your pubs repository is empty.')
|
||||
lines = out[-1].splitlines()
|
||||
self.assertEqual(lines[0], 'Repository statistics:')
|
||||
self.assertEqual(lines[1], 'Total papers: 4, 1 (25%) have a document attached')
|
||||
|
Loading…
x
Reference in New Issue
Block a user