diff --git a/bmc.py b/bmc.py index dcb4c1c..3b08ea6 100755 --- a/bmc.py +++ b/bmc.py @@ -630,13 +630,14 @@ if __name__ == '__main__': sys.exit() elif args.func == 'list': - listPapers = tools.listDir(config.get("folder")) + listPapers = backend.getEntries(full=True) + if not listPapers: + sys.exit() + listPapers = [v["file"] for k, v in listPapers.items()] listPapers.sort() - for paper in listPapers: - if tools.getExtension(paper) not in [".pdf", ".djvu"]: - continue print(paper) + sys.exit() elif args.func == 'search': raise Exception('TODO') diff --git a/libbmc/backend.py b/libbmc/backend.py index 21497a0..d3d67e3 100644 --- a/libbmc/backend.py +++ b/libbmc/backend.py @@ -277,7 +277,7 @@ def getBibtex(entry, file_id='both', clean=False): return bibtex_entry -def getEntries(): +def getEntries(full=False): """Returns the list of all entries in the bibtex index""" try: with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \ @@ -288,7 +288,10 @@ def getEntries(): tools.warning("Unable to open index file.") return False - return list(bibtex.keys()) + if full: + return bibtex + else: + return list(bibtex.keys()) def updateArXiv(entry): diff --git a/libbmc/tools.py b/libbmc/tools.py index 539d726..c566c77 100644 --- a/libbmc/tools.py +++ b/libbmc/tools.py @@ -14,7 +14,8 @@ from __future__ import print_function, unicode_literals import os import re import sys -from termios import tcflush, TCIOFLUSH +if os.name == "posix": + from termios import tcflush, TCIOFLUSH try: input = raw_input @@ -67,7 +68,8 @@ def replaceAll(text, dic): def rawInput(string): """Flush stdin and then prompt the user for something""" - tcflush(sys.stdin, TCIOFLUSH) + if os.name == "posix": + tcflush(sys.stdin, TCIOFLUSH) return input(string)