Reformat all python files
This commit is contained in:
parent
c0873f4343
commit
a3f4c2a932
6 changed files with 103 additions and 44 deletions
|
@ -3,10 +3,12 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
|
||||
# From https://github.com/python/cpython/blob/v3.7.0b5/Lib/site.py#L436
|
||||
# Changing the history file
|
||||
def register_readline() -> None:
|
||||
import atexit
|
||||
|
||||
try:
|
||||
import readline
|
||||
import rlcompleter
|
||||
|
@ -15,11 +17,11 @@ def register_readline() -> None:
|
|||
|
||||
# Reading the initialization (config) file may not be enough to set a
|
||||
# completion key, so we set one first and then read the file.
|
||||
readline_doc = getattr(readline, '__doc__', '')
|
||||
if readline_doc is not None and 'libedit' in readline_doc:
|
||||
readline.parse_and_bind('bind ^I rl_complete')
|
||||
readline_doc = getattr(readline, "__doc__", "")
|
||||
if readline_doc is not None and "libedit" in readline_doc:
|
||||
readline.parse_and_bind("bind ^I rl_complete")
|
||||
else:
|
||||
readline.parse_and_bind('tab: complete')
|
||||
readline.parse_and_bind("tab: complete")
|
||||
|
||||
try:
|
||||
readline.read_init_file()
|
||||
|
@ -36,12 +38,14 @@ def register_readline() -> None:
|
|||
# each interpreter exit when readline was already configured
|
||||
# through a PYTHONSTARTUP hook, see:
|
||||
# http://bugs.python.org/issue5845#msg198636
|
||||
history = os.path.join(os.path.expanduser('~'),
|
||||
'.cache/python_history')
|
||||
history = os.path.join(
|
||||
os.path.expanduser("~"), ".cache/python_history"
|
||||
)
|
||||
try:
|
||||
readline.read_history_file(history)
|
||||
except OSError:
|
||||
pass
|
||||
atexit.register(readline.write_history_file, history)
|
||||
|
||||
|
||||
sys.__interactivehook__ = register_readline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue