| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9a0ad31 commit 8ba24d1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -163,6 +163,7 @@ Dependencies | |||
| 163 | 163 | * babel (optional, for internationalization) | |
| 164 | 164 | * jedi (optional, for experimental multiline completion) | |
| 165 | 165 | * watchdog (optional, for monitoring imported modules for changes) | |
| 166 | + * pyperclip (optional, for copying to the clipboard) | ||
| 166 | 167 | ||
| 167 | 168 | bpython-urwid | |
| 168 | 169 | ------------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,12 +36,17 @@ | |||
| 36 | 36 | from enum import Enum | |
| 37 | 37 | from itertools import takewhile | |
| 38 | 38 | from pathlib import Path | |
| 39 | + from pygments.lexers import Python3Lexer | ||
| 40 | + from pygments.token import Token | ||
| 39 | 41 | from types import ModuleType | |
| 40 | 42 | ||
| 41 | - from pygments.token import Token | ||
| 42 | - from pygments.lexers import Python3Lexer | ||
| 43 | + have_pyperclip = True | ||
| 44 | + try: | ||
| 45 | + import pyperclip | ||
| 46 | + except ImportError: | ||
| 47 | + have_pyperclip = False | ||
| 48 | + | ||
| 43 | 49 | from . import autocomplete, inspection, simpleeval | |
| 44 | - from .clipboard import get_clipboard, CopyFailed | ||
| 45 | 50 | from .config import getpreferredencoding | |
| 46 | 51 | from .formatter import Parenthesis | |
| 47 | 52 | from .history import History | |
@@ -430,7 +435,6 @@ def __init__(self, interp, config): | |||
| 430 | 435 | # Necessary to fix mercurial.ui.ui expecting sys.stderr to have this | |
| 431 | 436 | # attribute | |
| 432 | 437 | self.closed = False | |
| 433 | - self.clipboard = get_clipboard() | ||
| 434 | 438 | ||
| 435 | 439 | if self.config.hist_file.exists(): | |
| 436 | 440 | try: | |
@@ -862,14 +866,14 @@ def write2file(self): | |||
| 862 | 866 | def copy2clipboard(self): | |
| 863 | 867 | """Copy current content to clipboard.""" | |
| 864 | 868 | ||
| 865 | - if self.clipboard is None: | ||
| 869 | + if not have_pyperclip: | ||
| 866 | 870 | self.interact.notify(_("No clipboard available.")) | |
| 867 | 871 | return | |
| 868 | 872 | ||
| 869 | 873 | content = self.get_session_formatted_for_file() | |
| 870 | 874 | try: | |
| 871 | - self.clipboard.copy(content) | ||
| 872 | - except CopyFailed: | ||
| 875 | + pyperclip.copy(content) | ||
| 876 | + except pyperclip.PyperclipException: | ||
| 873 | 877 | self.interact.notify(_("Could not copy to clipboard.")) | |
| 874 | 878 | else: | |
| 875 | 879 | self.interact.notify(_("Copied content to clipboard.")) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,9 +28,10 @@ install_requires = | |||
| 28 | 28 | pyxdg | |
| 29 | 29 | ||
| 30 | 30 | [options.extras_require] | |
| 31 | + clipboard = pyperclip | ||
| 32 | + jedi = jedi >= 0.16 | ||
| 31 | 33 | urwid = urwid | |
| 32 | 34 | watch = watchdog | |
| 33 | - jedi = jedi >= 0.16 | ||
| 34 | 35 | ||
| 35 | 36 | [options.entry_points] | |
| 36 | 37 | console_scripts = | |
| Back | FazBrowse Home | New Git URL |
0 commit comments