diff options
author | hut <hut@lavabit.com> | 2010-04-16 16:24:02 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-16 16:24:02 +0200 |
commit | 48ff03e6391057c17d7c0478c64f6ce8ae2f9d2a (patch) | |
tree | a92c8fb02c2858654db2f8b79466036cd51fb02c /ranger | |
parent | 2c9557d5164b0e31b9f7c1a36c0ac8bf8f002944 (diff) | |
download | ranger-48ff03e6391057c17d7c0478c64f6ce8ae2f9d2a.tar.gz |
keymap: replace to_string and is_ascii_digit with builtin methods
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/keymap.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py index b718c2a7..e09c9610 100644 --- a/ranger/container/keymap.py +++ b/ranger/container/keymap.py @@ -15,6 +15,7 @@ import curses.ascii from collections import deque +from string import digits from inspect import isfunction, getargspec from ranger.ext.tree import Tree from ranger.ext.direction import Direction @@ -27,16 +28,6 @@ DIRECTION = 'direction' DIRARG = 'dir' ALIASARG = 'alias' -def to_string(i): - """convert a ord'd integer to a string""" - try: - return chr(i) - except ValueError: - return '?' - -def is_ascii_digit(n): - return n >= 48 and n <= 57 - class CommandArgs(object): """The arguments which are passed to a keybinding function""" def __init__(self, fm, widget, keybuffer): @@ -232,7 +223,7 @@ class KeyBuffer(object): tree = self.tree_pointer else: tree = self.dir_tree_pointer - if is_ascii_digit(key) and ANYKEY not in tree: + if chr(key) in digits and ANYKEY not in tree: attr = self.eval_command and 'quant' or 'direction_quant' if getattr(self, attr) is None: setattr(self, attr, 0) @@ -251,7 +242,7 @@ class KeyBuffer(object): return None except KeyError: try: - is_ascii_digit(key) or self.direction_keys._tree[key] + chr(key) in digits or self.direction_keys._tree[key] self.tree_pointer = self.tree_pointer[DIRKEY] except KeyError: try: @@ -312,4 +303,4 @@ class KeyBuffer(object): def __str__(self): """returns a concatenation of all characters""" - return "".join(to_string(c) for c in self.all_keys) + return "".join("{0:c}".format(c) for c in self.all_keys) |