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