diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 22:29:57 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2021-01-31 22:29:57 -0500 |
| commit | f456b802754c3d1095b488d670bebba21018d823 (patch) | |
| tree | bf7011f585a8a35ab4cc7ff98aaeebed4de87f84 /cmd2/rl_utils.py | |
| parent | 918200c02d392c17862fff81bbf58820ed15c725 (diff) | |
| download | cmd2-git-f456b802754c3d1095b488d670bebba21018d823.tar.gz | |
Add black for automatic code format
Diffstat (limited to 'cmd2/rl_utils.py')
| -rw-r--r-- | cmd2/rl_utils.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/cmd2/rl_utils.py b/cmd2/rl_utils.py index ca75fd8a..44ce11ae 100644 --- a/cmd2/rl_utils.py +++ b/cmd2/rl_utils.py @@ -3,9 +3,7 @@ Imports the proper readline for the platform and provides utility functions for it """ import sys -from enum import ( - Enum, -) +from enum import Enum # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: @@ -23,6 +21,7 @@ except ImportError: class RlType(Enum): """Readline library types we recognize""" + GNU = 1 PYREADLINE = 2 NONE = 3 @@ -107,7 +106,7 @@ if 'pyreadline' in sys.modules or 'pyreadline3' in sys.modules: saved_cursor = readline.rl.mode._history.history_cursor # Delete the history item - del(readline.rl.mode._history.history[pos]) + del readline.rl.mode._history.history[pos] # Update the cursor if needed if saved_cursor > pos: @@ -121,10 +120,13 @@ elif 'gnureadline' in sys.modules or 'readline' in sys.modules: try: # Load the readline lib so we can access members of it import ctypes + readline_lib = ctypes.CDLL(readline.__file__) except AttributeError: # pragma: no cover - _rl_warn_reason = ("this application is running in a non-standard Python environment in\n" - "which readline is not loaded dynamically from a shared library file.") + _rl_warn_reason = ( + "this application is running in a non-standard Python environment in\n" + "which readline is not loaded dynamically from a shared library file." + ) else: rl_type = RlType.GNU vt100_support = sys.stdout.isatty() @@ -132,10 +134,11 @@ elif 'gnureadline' in sys.modules or 'readline' in sys.modules: # Check if readline was loaded if rl_type == RlType.NONE: # pragma: no cover if not _rl_warn_reason: - _rl_warn_reason = ("no supported version of readline was found. To resolve this, install\n" - "pyreadline on Windows or gnureadline on Mac.") - rl_warning = ("Readline features including tab completion have been disabled because\n" - + _rl_warn_reason + '\n\n') + _rl_warn_reason = ( + "no supported version of readline was found. To resolve this, install\n" + "pyreadline on Windows or gnureadline on Mac." + ) + rl_warning = "Readline features including tab completion have been disabled because\n" + _rl_warn_reason + '\n\n' else: rl_warning = '' |
