Fix on Windows + Fix issue #25

This commit is contained in:
Phyks 2015-06-09 12:02:54 +02:00
parent 84a7a1cd63
commit 82ed48a9e0
3 changed files with 14 additions and 8 deletions

9
bmc.py
View File

@ -630,13 +630,14 @@ if __name__ == '__main__':
sys.exit() sys.exit()
elif args.func == 'list': 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() listPapers.sort()
for paper in listPapers: for paper in listPapers:
if tools.getExtension(paper) not in [".pdf", ".djvu"]:
continue
print(paper) print(paper)
sys.exit()
elif args.func == 'search': elif args.func == 'search':
raise Exception('TODO') raise Exception('TODO')

View File

@ -277,7 +277,7 @@ def getBibtex(entry, file_id='both', clean=False):
return bibtex_entry return bibtex_entry
def getEntries(): def getEntries(full=False):
"""Returns the list of all entries in the bibtex index""" """Returns the list of all entries in the bibtex index"""
try: try:
with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \ with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \
@ -288,7 +288,10 @@ def getEntries():
tools.warning("Unable to open index file.") tools.warning("Unable to open index file.")
return False return False
return list(bibtex.keys()) if full:
return bibtex
else:
return list(bibtex.keys())
def updateArXiv(entry): def updateArXiv(entry):

View File

@ -14,7 +14,8 @@ from __future__ import print_function, unicode_literals
import os import os
import re import re
import sys import sys
from termios import tcflush, TCIOFLUSH if os.name == "posix":
from termios import tcflush, TCIOFLUSH
try: try:
input = raw_input input = raw_input
@ -67,7 +68,8 @@ def replaceAll(text, dic):
def rawInput(string): def rawInput(string):
"""Flush stdin and then prompt the user for something""" """Flush stdin and then prompt the user for something"""
tcflush(sys.stdin, TCIOFLUSH) if os.name == "posix":
tcflush(sys.stdin, TCIOFLUSH)
return input(string) return input(string)