summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__init__.py83
-rw-r--r--ranger/__main__.py79
2 files changed, 84 insertions, 78 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py
index 5eaaee4f..264aa931 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -1,4 +1,6 @@
 """Ranger - file browser for the unix terminal"""
+import os
+import sys
 
 __copyright__ = 'none'
 __license__ = 'GPL'
@@ -8,12 +10,6 @@ __author__ = 'hut'
 __maintainer__ = 'hut'
 __email__ = 'hut@lavabit.com'
 
-import os
-import sys
-
-# for easier access
-from ranger.ext.debug import log, trace
-
 CONFDIR = os.path.expanduser('~/.ranger')
 RANGERDIR = os.path.dirname(__file__)
 
@@ -21,76 +17,7 @@ sys.path.append(CONFDIR)
 
 USAGE = '''%s [options] [path/filename]'''
 
-def main():
-	"""initialize objects and run the filemanager"""
-	try:
-		import curses
-	except ImportError as errormessage:
-		print(errormessage)
-		print('ranger requires the python curses module. Aborting.')
-		sys.exit(1)
-
-	from locale import setlocale, LC_ALL
-	from optparse import OptionParser, SUPPRESS_HELP
-
-	from ranger.fm import FM
-	from ranger.container.environment import Environment
-	from ranger.shared.settings import SettingsAware
-	from ranger.gui.defaultui import DefaultUI as UI
-	from ranger.fsobject.file import File
-
-	setlocale(LC_ALL, 'en_US.utf8')
-	os.stat_float_times(True)
-
-	# Parse options
-	parser = OptionParser( usage = USAGE,
-			version = 'ranger ' + __version__ )
-
-	# Instead of using this directly, use the embedded
-	# shell script by running ranger with:
-	# source /path/to/ranger /path/to/ranger
-	parser.add_option( '--cd-after-exit',
-			action = 'store_true',
-			dest = 'cd_after_exit',
-			help = SUPPRESS_HELP )
-
-	args, rest = parser.parse_args()
-
-	log(sys.argv)
-	if args.cd_after_exit:
-		sys.stderr = sys.__stdout__
-	
-	# Initialize objects
-	target = ' '.join(rest)
-	if target:
-		if not os.access(target, os.F_OK):
-			print("File or directory doesn't exist: %s" % target)
-			sys.exit(1)
-		elif os.path.isfile(target):
-			thefile = File(target)
-			FM().execute_file(thefile)
-			sys.exit(0)
-		else:
-			path = target
-	else:
-		path = '.'
-
-	SettingsAware._setup()
-	Environment(path)
-
-	try:
-		my_ui = UI()
-		my_fm = FM(ui=my_ui)
-		my_fm.stderr_to_out = args.cd_after_exit
+# for easier access
+from ranger.ext.debug import log, trace
 
-		# Run the file manager
-		my_fm.initialize()
-		my_ui.initialize()
-		my_fm.loop()
-	finally:
-		# Finish, clean up
-		if 'my_ui' in vars():
-			my_ui.destroy()
-		if args.cd_after_exit:
-			try: sys.__stderr__.write(my_fm.env.pwd.path)
-			except: pass
+from ranger.__main__ import main
diff --git a/ranger/__main__.py b/ranger/__main__.py
new file mode 100644
index 00000000..200d856b
--- /dev/null
+++ b/ranger/__main__.py
@@ -0,0 +1,79 @@
+import os
+import sys
+
+def main():
+	"""initialize objects and run the filemanager"""
+	try:
+		import curses
+	except ImportError as errormessage:
+		print(errormessage)
+		print('ranger requires the python curses module. Aborting.')
+		sys.exit(1)
+
+	from locale import setlocale, LC_ALL
+	from optparse import OptionParser, SUPPRESS_HELP
+
+	from ranger import __version__, USAGE
+	from ranger.fm import FM
+	from ranger.container.environment import Environment
+	from ranger.shared.settings import SettingsAware
+	from ranger.gui.defaultui import DefaultUI as UI
+	from ranger.fsobject.file import File
+
+	setlocale(LC_ALL, 'en_US.utf8')
+	os.stat_float_times(True)
+
+	# Parse options
+	parser = OptionParser( usage = USAGE,
+			version = 'ranger ' + __version__ )
+
+	# Instead of using this directly, use the embedded
+	# shell script by running ranger with:
+	# source /path/to/ranger /path/to/ranger
+	parser.add_option( '--cd-after-exit',
+			action = 'store_true',
+			dest = 'cd_after_exit',
+			help = SUPPRESS_HELP )
+
+	args, rest = parser.parse_args()
+
+	if args.cd_after_exit:
+		sys.stderr = sys.__stdout__
+	
+	# Initialize objects
+	target = ' '.join(rest)
+	if target:
+		if not os.access(target, os.F_OK):
+			print("File or directory doesn't exist: %s" % target)
+			sys.exit(1)
+		elif os.path.isfile(target):
+			thefile = File(target)
+			FM().execute_file(thefile)
+			sys.exit(0)
+		else:
+			path = target
+	else:
+		path = '.'
+
+	SettingsAware._setup()
+	Environment(path)
+
+	try:
+		my_ui = UI()
+		my_fm = FM(ui=my_ui)
+		my_fm.stderr_to_out = args.cd_after_exit
+
+		# Run the file manager
+		my_fm.initialize()
+		my_ui.initialize()
+		my_fm.loop()
+	finally:
+		# Finish, clean up
+		if 'my_ui' in vars():
+			my_ui.destroy()
+		if args.cd_after_exit:
+			try: sys.__stderr__.write(my_fm.env.pwd.path)
+			except: pass
+
+if __name__ == '__main__':
+	main()
re>
b439892 ^
caf5a16 ^
901b3ed ^
1076f2b

901b3ed ^
0c3544d ^
2b35fae ^

a3e3f0b ^

2b35fae ^
3e06ede ^
cdbc84b ^
338c083 ^
292ccc4 ^
d4b7a9a ^
10885d3 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
72655f0 ^
ee8fb0c ^
df74b26 ^
0ea0343 ^
72655f0 ^
ee8fb0c ^
5871008 ^
cb9607c ^
fef6c5c ^


aa53e39 ^


ee8fb0c ^
7ab8c87 ^
72655f0 ^
ee8fb0c ^
7ab8c87 ^
3af6434 ^
85c9ebf ^
aa53e39 ^
9066ee2 ^
ee8fb0c ^
338c083 ^
352cae4 ^
ee8fb0c ^
1549faf ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
42fd392 ^

ee8fb0c ^
df74b26 ^
7ab8c87 ^

df74b26 ^
ee8fb0c ^
7ab8c87 ^
45aea23 ^
ee8fb0c ^
338c083 ^
1549faf ^
ee8fb0c ^
a92cf49 ^
8dc8605 ^
ee8fb0c ^
df74b26 ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
7ab8c87 ^
daae3bb ^
ee8fb0c ^
3e06ede ^
7ab8c87 ^

4bb89e2 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
0c3544d ^
ee8fb0c ^
338c083 ^
0e5c819 ^
ee8fb0c ^
5871008 ^
4bd0d33 ^
ee8fb0c ^
338c083 ^
0c3544d ^
7ab8c87 ^
dc5c070 ^
7e98db2 ^

bced907 ^
60b3dce ^
21bd90d ^
c8f96b5 ^
4bb89e2 ^
c8f96b5 ^



c7da124 ^


c8f96b5 ^

124866e ^







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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153