| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 932bfe5 commit 589a867
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,11 @@ | |||
| 25 | 25 | import platform | |
| 26 | 26 | from locale import getpreferredencoding | |
| 27 | 27 | ||
| 28 | + | ||
| 28 | 29 | class CopyFailed(Exception): | |
| 29 | 30 | pass | |
| 30 | 31 | ||
| 32 | + | ||
| 31 | 33 | class XClipboard(object): | |
| 32 | 34 | """Manage clipboard with xclip.""" | |
| 33 | 35 | ||
@@ -38,6 +40,7 @@ def copy(self, content): | |||
| 38 | 40 | if process.returncode != 0: | |
| 39 | 41 | raise CopyFailed() | |
| 40 | 42 | ||
| 43 | + | ||
| 41 | 44 | class OSXClipboard(object): | |
| 42 | 45 | """Manage clipboard with pbcopy.""" | |
| 43 | 46 | ||
@@ -47,13 +50,15 @@ def copy(self, content): | |||
| 47 | 50 | if process.returncode != 0: | |
| 48 | 51 | raise CopyFailed() | |
| 49 | 52 | ||
| 53 | + | ||
| 50 | 54 | def command_exists(command): | |
| 51 | 55 | process = subprocess.Popen(['which', command], stderr=subprocess.STDOUT, | |
| 52 | 56 | stdout=subprocess.PIPE) | |
| 53 | 57 | process.communicate() | |
| 54 | 58 | ||
| 55 | 59 | return process.returncode == 0 | |
| 56 | 60 | ||
| 61 | + | ||
| 57 | 62 | def get_clipboard(): | |
| 58 | 63 | """Get best clipboard handling implemention for current system.""" | |
| 59 | 64 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,15 +30,18 @@ def can_encode(c): | |||
| 30 | 30 | except UnicodeEncodeError: | |
| 31 | 31 | return False | |
| 32 | 32 | ||
| 33 | + | ||
| 33 | 34 | def supports_box_chars(): | |
| 34 | 35 | """Check if the encoding suppors Unicode box characters.""" | |
| 35 | 36 | return all(map(can_encode, u'│─└┘┌┐')) | |
| 36 | 37 | ||
| 38 | + | ||
| 37 | 39 | def get_config_home(): | |
| 38 | 40 | """Returns the base directory for bpython's configuration files.""" | |
| 39 | 41 | xdg_config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') | |
| 40 | 42 | return os.path.join(xdg_config_home, 'bpython') | |
| 41 | 43 | ||
| 44 | + | ||
| 42 | 45 | def default_config_path(): | |
| 43 | 46 | """Returns bpython's default configuration file path.""" | |
| 44 | 47 | return os.path.join(get_config_home(), 'config') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,8 @@ | |||
| 26 | 26 | ||
| 27 | 27 | from pygments.formatter import Formatter | |
| 28 | 28 | from pygments.token import Keyword, Name, Comment, String, Error, \ | |
| 29 | - Number, Operator, Token, Whitespace, Literal, Punctuation | ||
| 29 | + Number, Operator, Token, Whitespace, Literal, \ | ||
| 30 | + Punctuation | ||
| 30 | 31 | from six import iteritems | |
| 31 | 32 | ||
| 32 | 33 | """These format strings are pretty ugly. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,6 +98,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): | |||
| 98 | 98 | setattr(type_, '__getattr__', __getattr__) | |
| 99 | 99 | # /Dark magic | |
| 100 | 100 | ||
| 101 | + | ||
| 101 | 102 | class _Repr(object): | |
| 102 | 103 | """ | |
| 103 | 104 | Helper for `fixlongargs()`: Returns the given value in `__repr__()`. | |
@@ -111,6 +112,7 @@ def __repr__(self): | |||
| 111 | 112 | ||
| 112 | 113 | __str__ = __repr__ | |
| 113 | 114 | ||
| 115 | + | ||
| 114 | 116 | def parsekeywordpairs(signature): | |
| 115 | 117 | tokens = PythonLexer().get_tokens(signature) | |
| 116 | 118 | preamble = True | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,7 +54,7 @@ def __setitem__(self, key, value): | |||
| 54 | 54 | # fill dispatch with letters | |
| 55 | 55 | for c in string.ascii_lowercase: | |
| 56 | 56 | cli_key_dispatch['C-%s' % c] = (chr(string.ascii_lowercase.index(c) + 1), | |
| 57 | - '^%s' % c.upper()) | ||
| 57 | + '^%s' % c.upper()) | ||
| 58 | 58 | ||
| 59 | 59 | for c in string.ascii_lowercase: | |
| 60 | 60 | urwid_key_dispatch['C-%s' % c] = 'ctrl %s' % c | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ | |||
| 29 | 29 | import sys | |
| 30 | 30 | import shlex | |
| 31 | 31 | ||
| 32 | + | ||
| 32 | 33 | def get_pager_command(default='less -rf'): | |
| 33 | 34 | command = shlex.split(os.environ.get('PAGER', default)) | |
| 34 | 35 | return command | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ | |||
| 10 | 10 | from bpython.translations import init | |
| 11 | 11 | from bpython._py3compat import py3 | |
| 12 | 12 | ||
| 13 | + | ||
| 13 | 14 | class FixLanguageTestCase(unittest.TestCase): | |
| 14 | 15 | ||
| 15 | 16 | @classmethod | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | except ImportError: | |
| 9 | 9 | import unittest | |
| 10 | 10 | ||
| 11 | + | ||
| 11 | 12 | class TestExecArgs(unittest.TestCase): | |
| 12 | 13 | def test_exec_dunder_file(self): | |
| 13 | 14 | with tempfile.NamedTemporaryFile(mode="w") as f: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | TEST_THEME_PATH = os.path.join(os.path.dirname(__file__), "test.theme") | |
| 13 | 13 | ||
| 14 | + | ||
| 14 | 15 | class TestConfig(unittest.TestCase): | |
| 15 | 16 | def load_temp_config(self, content, struct=None): | |
| 16 | 17 | """Write config to a temporary file and load it.""" | |
@@ -35,7 +36,8 @@ def test_load_theme(self): | |||
| 35 | 36 | ||
| 36 | 37 | defaults = {"name": "c"} | |
| 37 | 38 | expected.update(defaults) | |
| 38 | - config.load_theme(struct, TEST_THEME_PATH, struct.color_scheme, defaults) | ||
| 39 | + config.load_theme(struct, TEST_THEME_PATH, struct.color_scheme, | ||
| 40 | + defaults) | ||
| 39 | 41 | self.assertEquals(struct.color_scheme, expected) | |
| 40 | 42 | ||
| 41 | 43 | def test_keybindings_default_contains_no_duplicates(self): | |
@@ -90,4 +92,3 @@ def test_keybindings_unused(self): | |||
| 90 | 92 | """)) | |
| 91 | 93 | ||
| 92 | 94 | self.assertEqual(struct.help_key, 'F4') | |
| 93 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | from bpython.history import History | |
| 7 | 7 | ||
| 8 | + | ||
| 8 | 9 | class TestHistory(unittest.TestCase): | |
| 9 | 10 | def setUp(self): | |
| 10 | 11 | self.history = History('#%d' % x for x in range(1000)) | |
@@ -74,7 +75,6 @@ def test_enter_2(self): | |||
| 74 | 75 | self.assertEqual(self.history.back(), '#508') | |
| 75 | 76 | self.assertEqual(self.history.forward(), '#509') | |
| 76 | 77 | ||
| 77 | - | ||
| 78 | 78 | def test_reset(self): | |
| 79 | 79 | self.history.enter('#lastnumber!') | |
| 80 | 80 | self.history.reset() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments