improves chronological listing (year, month), adds test
This commit is contained in:
parent
e1f56fb212
commit
b3e9db62e1
@ -48,8 +48,8 @@ def command(conf, args):
|
|||||||
papers = [p for p in papers if p.docpath is None]
|
papers = [p for p in papers if p.docpath is None]
|
||||||
if args.alphabetical:
|
if args.alphabetical:
|
||||||
papers = sorted(papers, key=lambda p: p.citekey)
|
papers = sorted(papers, key=lambda p: p.citekey)
|
||||||
if args.chronological:
|
elif args.chronological:
|
||||||
papers = sorted(papers, key=lambda p: p.bibdata['year'])
|
papers = sorted(papers, key=lambda p: ('year' not in p.bibdata, p.bibdata.get('year'), p.bibdata.get('month'), date_added))
|
||||||
else:
|
else:
|
||||||
papers = sorted(papers, key=date_added)
|
papers = sorted(papers, key=date_added)
|
||||||
if len(papers) > 0:
|
if len(papers) > 0:
|
||||||
|
5
tests/bibexamples/noyear.bib
Normal file
5
tests/bibexamples/noyear.bib
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@article{Doe_noyear,
|
||||||
|
title={About Assigning Timestamps to Research Articles},
|
||||||
|
author={Doe, John},
|
||||||
|
journal={Journal Example},
|
||||||
|
}
|
@ -516,6 +516,28 @@ class TestList(DataCommandTestCase):
|
|||||||
self.assertEqual(0, len(outs[3].splitlines()))
|
self.assertEqual(0, len(outs[3].splitlines()))
|
||||||
self.assertEqual(1, len(outs[4].splitlines()))
|
self.assertEqual(1, len(outs[4].splitlines()))
|
||||||
|
|
||||||
|
def test_list_chronological_order(self):
|
||||||
|
cmds = ['pubs init',
|
||||||
|
'pubs import data/',
|
||||||
|
'pubs list --chronological',
|
||||||
|
'pubs import bibexamples/noyear.bib',
|
||||||
|
'pubs list -C',
|
||||||
|
|
||||||
|
]
|
||||||
|
data_chrono_correct = '[Einstein_1935] Einstein, A. et al. "Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?" Physical Review (1935) \n' \
|
||||||
|
'[Schrodinger_1935] Schrödinger, E. and Born, M. "Discussion of Probability Relations between Separated Systems" Mathematical Proceedings of the Cambridge Philosophical Society (1935) \n' \
|
||||||
|
'[turing1950computing] Turing, Alan M "Computing machinery and intelligence" Mind (1950) \n' \
|
||||||
|
'[Bell_1964] Bell, J. S. "On the Einstein Podolsky Rosen paradox" Physics Physique физика (1964) \n' \
|
||||||
|
'[Page99] Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web." (1999) \n' \
|
||||||
|
'[10.1371_journal.pone.0038236] Saunders, Caroline Lyon AND Chrystopher L. Nehaniv AND Joe "Interactive Language Learning by Robots: The Transition from Babbling to Word Forms" PLoS ONE (2012) \n' \
|
||||||
|
'[10.1371_journal.pone.0063400] Ay, Georg Martius AND Ralf Der AND Nihat "Information Driven Self-Organization of Complex Robotic Behaviors" PLoS ONE (2013) \n' \
|
||||||
|
'[Cesar2013] César, Jean "An amazing title" Nice Journal (2013) \n'
|
||||||
|
correct = [ data_chrono_correct,
|
||||||
|
data_chrono_correct + '[Doe_noyear] Doe, John "About Assigning Timestamps to Research Articles" Journal Example \n'
|
||||||
|
]
|
||||||
|
outs = self.execute_cmds(cmds)
|
||||||
|
self.assertEqual(outs[2], correct[0])
|
||||||
|
self.assertEqual(outs[4], correct[1])
|
||||||
|
|
||||||
class TestTag(DataCommandTestCase):
|
class TestTag(DataCommandTestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user