summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-06 14:23:57 +0100
committerhut <hut@lavabit.com>2009-12-06 14:23:57 +0100
commit47d269365a9789646a06cdc6f533999561c7fef4 (patch)
tree1539808fe64354ef9067d4c97f8b4cfeeceef014 /ranger
parent373fdb3b29eeda84beef7f4096e523919ae9b3cb (diff)
downloadranger-47d269365a9789646a06cdc6f533999561c7fef4.tar.gz
fix/clean ranger.helper
Diffstat (limited to 'ranger')
-rw-r--r--ranger/helper.py44
1 files changed, 23 insertions, 21 deletions
diff --git a/ranger/helper.py b/ranger/helper.py
index 086d7b09..d9f6270d 100644
--- a/ranger/helper.py
+++ b/ranger/helper.py
@@ -8,16 +8,12 @@ def log(txt):
 	f.write("\n")
 	f.close()
 
-ONE_KB = 1024
-UNITS = tuple('BKMGTP')
-NINE_THOUSAND = len(UNITS) - 1
-
 class OpenStruct(object):
 	def __init__(self, __dictionary=None, **__keywords):
 		if __dictionary:
 			self.__dict__.update(__dictionary)
 		if __keywords:
-			self.__dict__.update(keywords)
+			self.__dict__.update(__keywords)
 
 	def __getitem__(self, key):
 		return self.__dict__[key]
@@ -29,14 +25,19 @@ class OpenStruct(object):
 	def __contains__(self, key):
 		return key in self.__dict__
 
+# used to get all colorschemes in ~/.ranger/colorschemes and ranger/colorschemes
 def get_all(dirname):
 	import os
-	lst = []
-	for f in os.listdir(dirname):
-		if f.endswith('.py') and not f.startswith('_'):
-			lst.append(f [0:f.index('.')])
-	return lst
+	result = []
+	for filename in os.listdir(dirname):
+		if filename.endswith('.py') and not filename.startswith('_'):
+			result.append(filename[0:filename.index('.')])
+	return result
+
 
+ONE_KB = 1024
+UNITS = 'BKMGTP'
+MAX_EXPONENT = len(UNITS) - 1
 
 def human_readable(byte):
 	import math
@@ -44,19 +45,20 @@ def human_readable(byte):
 	if not byte:
 		return '0 B'
 
-	its = int(math.log(byte, 2) / 10)
-	flt = float(byte) / (1 << (10 * its))
+	exponent = int(math.log(byte, 2) / 10)
+	flt = float(byte) / (1 << (10 * exponent))
 	
-	if its > NINE_THOUSAND:
+	if exponent > MAX_EXPONENT:
 		return '>9000' # off scale
 
 	if int(flt) == flt:
-		return '%.0f %s' % (flt, UNITS[its])
+		return '%.0f %s' % (flt, UNITS[exponent])
 
 	else:
-		return '%.2f %s' % (flt, UNITS[its])
+		return '%.2f %s' % (flt, UNITS[exponent])
 
 def waitpid_no_intr(pid):
+	""" catch interrupts which occur while using os.waitpid """
 	import os, errno
 
 	while True:
@@ -92,15 +94,15 @@ def popen(*args, **kw):
 	
 	if 'p' in flags:
 		popen_kw['stdout'] = PIPE
-		p1 = Popen(args, **popen_kw)
-		kw['stdin'] = p1.stdout
+		process1 = Popen(args, **popen_kw)
+		kw['stdin'] = process1.stdout
 		kw['files'] = ()
 		kw['flags'] = ''.join(f for f in kw['flags'] if f in 'd')
-		p2 = kw['apps'].app_pager(**kw)
-		return p2
+		process2 = kw['apps'].app_pager(**kw)
+		return process2
 	if 'd' in flags:
-		p = Popen(args, **popen_kw)
-		return p
+		process = Popen(args, **popen_kw)
+		return process
 	else:
 		fm.ui.exit()
 		p = Popen(args, **popen_kw)
='alt'>
e9e4b4ff ^

50a0cb1c ^
e9e4b4ff ^

26aa5c8e ^
e9e4b4ff ^
fde932f2 ^
75682d43 ^
e9e4b4ff ^

2c5ea01d ^
e9e4b4ff ^




e9e4b4ff ^

2c5ea01d ^
e9e4b4ff ^
0c2c782d ^

30ae2137 ^
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