Fix on Windows + Fix issue #25
This commit is contained in:
parent
84a7a1cd63
commit
82ed48a9e0
9
bmc.py
9
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')
|
||||
|
@ -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,6 +288,9 @@ def getEntries():
|
||||
tools.warning("Unable to open index file.")
|
||||
return False
|
||||
|
||||
if full:
|
||||
return bibtex
|
||||
else:
|
||||
return list(bibtex.keys())
|
||||
|
||||
|
||||
|
@ -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,6 +68,7 @@ def replaceAll(text, dic):
|
||||
|
||||
def rawInput(string):
|
||||
"""Flush stdin and then prompt the user for something"""
|
||||
if os.name == "posix":
|
||||
tcflush(sys.stdin, TCIOFLUSH)
|
||||
return input(string)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user