FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

KeyMap object to facilitate custom exceptions (now we need to check v… · di/bpython@4efb1e5 · GitHub

/ bpython Public
forked from bpython/bpython

Commit 4efb1e5

Browse files
committed
KeyMap object to facilitate custom exceptions (now we need to check valid keys on startup)
1 parent 299d566 commit 4efb1e5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎bpython/keys.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@
2525

2626
import string
2727

28-
key_dispatch = {}
28+
class KeyMap:
29+
def __init__(self):
30+
self.map = {}
31+
32+
def __getitem__(self, key):
33+
if key in self.map:
34+
return self.map[key]
35+
else:
36+
raise Exception('Configured keymap (%s) does not exist in bpython.keys' % key)
37+
38+
def __setitem__(self, key, value):
39+
self.map[key] = value
40+
41+
key_dispatch = KeyMap()
2942

3043
# fill dispatch with letters
3144
for c in string.lowercase:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL