summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__main__.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index 8fdc5a24..e3d98d6e 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -16,29 +16,19 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# Most import statements in this module are inside the functions.
+# This enables more convenient exception handling in ranger.py
+# (ImportError will imply that this module can't be found)
+# convenient exception handling in ranger.py (ImportError)
+
 import os
 import sys
-import ranger
-
-from optparse import OptionParser, SUPPRESS_HELP
-from ranger.ext.openstruct import OpenStruct
-from ranger import __version__, USAGE, DEFAULT_CONFDIR
-import ranger.api.commands
-
-from signal import signal, SIGINT
-from locale import getdefaultlocale, setlocale, LC_ALL
-
-from ranger.ext import curses_interrupt_handler
-from ranger.core.runner import Runner
-from ranger.core.fm import FM
-from ranger.core.environment import Environment
-from ranger.shared import (EnvironmentAware, FileManagerAware,
-		SettingsAware)
-from ranger.gui.defaultui import DefaultUI as UI
-from ranger.fsobject import File
 
 def parse_arguments():
 	"""Parse the program arguments"""
+	from optparse import OptionParser, SUPPRESS_HELP
+	from ranger import __version__, USAGE, DEFAULT_CONFDIR
+	from ranger.ext.openstruct import OpenStruct
 	parser = OptionParser(usage=USAGE, version='ranger ' + __version__)
 
 	parser.add_option('-d', '--debug', action='store_true',
@@ -83,6 +73,8 @@ def allow_access_to_confdir(confdir, allow):
 
 
 def load_settings(fm, clean):
+	import ranger
+	import ranger.api.commands
 	if not clean:
 		allow_access_to_confdir(ranger.arg.confdir, True)
 
@@ -132,6 +124,7 @@ def load_settings(fm, clean):
 
 
 def load_apps(fm, clean):
+	import ranger
 	if not clean:
 		allow_access_to_confdir(ranger.arg.confdir, True)
 		try:
@@ -152,6 +145,16 @@ def main():
 		print(errormessage)
 		print('ranger requires the python curses module. Aborting.')
 		sys.exit(1)
+	from locale import getdefaultlocale, setlocale, LC_ALL
+	import ranger
+	from ranger.ext import curses_interrupt_handler
+	from ranger.core.runner import Runner
+	from ranger.core.fm import FM
+	from ranger.core.environment import Environment
+	from ranger.gui.defaultui import DefaultUI as UI
+	from ranger.fsobject import File
+	from ranger.shared import (EnvironmentAware, FileManagerAware,
+			SettingsAware)
 
 	# Ensure that a utf8 locale is set.
 	try:
;silvino@bk.ru> 2018-12-08 02:08:20 +0000 committer Silvino Silva <silvino@bk.ru> 2018-12-08 02:08:20 +0000 iptables revision' href='/punk/doc/commit/core/conf/iptables/ipt-server.sh?id=b6b79e6d960febc3f266735e4a2f807d776b5830'>b6b79e6 ^
36ef494 ^
c3a272d ^
36ef494 ^
b6b79e6 ^





c3a272d ^
36ef494 ^
b6b79e6 ^
d9ddaa4 ^
b6b79e6 ^
36ef494 ^
b6b79e6 ^


c3a272d ^
c3a272d ^

045ea9a ^



eddfa5e ^
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