summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-16 16:24:02 +0200
committerhut <hut@lavabit.com>2010-04-16 16:24:02 +0200
commit48ff03e6391057c17d7c0478c64f6ce8ae2f9d2a (patch)
treea92c8fb02c2858654db2f8b79466036cd51fb02c
parent2c9557d5164b0e31b9f7c1a36c0ac8bf8f002944 (diff)
downloadranger-48ff03e6391057c17d7c0478c64f6ce8ae2f9d2a.tar.gz
keymap: replace to_string and is_ascii_digit with builtin methods
-rw-r--r--ranger/container/keymap.py17
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)
James Booth <boothj5@gmail.com> 2016-09-25 23:30:44 +0100 committer James Booth <boothj5@gmail.com> 2016-09-25 23:30:44 +0100 Fix assertion errors in unit tests' href='/danisanti/profani-tty/commit/tests/unittests/test_server_events.c?id=a48df40138d0e7f3709a2ab45157f5696b6f861b'>a48df401 ^
055a5f71 ^
6d39f49f ^
a2c62117 ^

ae08e820 ^
a7a28506 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
0e2fbeb3 ^
055a5f71 ^
a48df401 ^
a7a28506 ^



a7a28506 ^
a48df401 ^
055a5f71 ^
6d39f49f ^
a2c62117 ^

ae08e820 ^
0e2fbeb3 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
a7a28506 ^
055a5f71 ^
a48df401 ^
a7a28506 ^



a7a28506 ^
a48df401 ^
055a5f71 ^
6d39f49f ^
a2c62117 ^

ae08e820 ^
a7a28506 ^
a2c62117 ^


0e2fbeb3 ^
8ebc1d4a ^
0e2fbeb3 ^
055a5f71 ^
a48df401 ^
a7a28506 ^
5afb296e ^
95ad5643 ^

a48df401 ^
055a5f71 ^
6d39f49f ^
95ad5643 ^


95ad5643 ^


51bd4ed3 ^
055a5f71 ^


8aba52f4 ^
9bd2315d ^
95ad5643 ^
9bd2315d ^
95ad5643 ^
055a5f71 ^
95ad5643 ^
a48df401 ^
95ad5643 ^
f180925c ^


055a5f71 ^
6d39f49f ^
f180925c ^
51bd4ed3 ^

f180925c ^

8aba52f4 ^
f180925c ^





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119