예제 #1
0
파일: utils.py 프로젝트: 403JFW/akatsuki
    def test_sort_by_date(self):
        # Test data
        entry_first = {
            'title': 'First',
            'year': 2012,
            'month': 'Jan'}
        entry_second = {
            'title': 'Second',
            'year': 2012,
            'month': 'Oct'}
        entry_third = {
            'title': 'Third',
            'year': 2013}
        entry_fourth = {
            'title': 'Third',
            'year': 2013,
            'month': 'Feb'}
        entries = [entry_second, entry_first, entry_fourth, entry_third]
        expected_result = [
            entry_first,
            entry_second,
            entry_third,
            entry_fourth]

        # Test sort by date
        result = utils.sort_by_date(entries)
        for es in zip(result, expected_result):
            self.assertEqual(es[0], es[1])

        # Test reverse sort by date
        expected_result = expected_result[::-1]
        result = utils.sort_by_date(entries, reverse=True)
        for es in zip(result, expected_result):
            self.assertEqual(es[0], es[1])
예제 #2
0
def main(bibtex_file, html_file):
    """Load BibTeX file and export to WordPress HTML file"""
    entries = load_bibtex_file(bibtex_file)
    entries = pmid_to_url(entries)
    entries = sort_by_date(entries, reverse=True)
    export_wordpress(html_file, entries)