Merge pull request #751 from micahellison/readline-738

[GH-738] preventing readline usage on Windows
This commit is contained in:
Jonathan Wren 2019-11-25 20:42:33 -08:00 committed by GitHub
commit 0c1b577208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python
import readline
import glob
import getpass
import os
@ -14,6 +13,9 @@ from .util import UserAbort
import yaml
import logging
import sys
if "win32" not in sys.platform:
# readline is not included in Windows Active Python
import readline
DEFAULT_CONFIG_NAME = 'jrnl.yaml'
DEFAULT_JOURNAL_NAME = 'journal.txt'
@ -108,14 +110,10 @@ def load_or_install_jrnl():
def install():
def autocomplete(text, state):
expansions = glob.glob(os.path.expanduser(os.path.expandvars(text)) + '*')
expansions = [e + "/" if os.path.isdir(e) else e for e in expansions]
expansions.append(None)
return expansions[state]
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(autocomplete)
if "win32" not in sys.platform:
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(autocomplete)
# Where to create the journal?
path_query = f'Path to your journal file (leave blank for {JOURNAL_FILE_PATH}): '
@ -146,3 +144,9 @@ def install():
if password:
config['password'] = password
return config
def autocomplete(text, state):
expansions = glob.glob(os.path.expanduser(os.path.expandvars(text)) + '*')
expansions = [e + "/" if os.path.isdir(e) else e for e in expansions]
expansions.append(None)
return expansions[state]