summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__init__.py23
-rw-r--r--ranger/core/helper.py14
2 files changed, 13 insertions, 24 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py
index 0245988e..324cea55 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -24,9 +24,7 @@ The keybindings are similar to those of other console programs like
 vim, mutt or ncmpcpp so the usage will be intuitive and efficient.
 """
 
-from os import path, environ
-from ranger.ext.openstruct import OpenStruct
-from sys import argv
+import os
 from ranger.core.main import main
 
 # Information
@@ -36,21 +34,4 @@ __author__ = __maintainer__ = 'Roman Zimbelmann'
 __email__ = 'romanz@lavabit.com'
 
 # Constants
-USAGE = '%prog [options] [path/filename]'
-RANGERDIR = path.dirname(__file__)
-LOGFILE = '/tmp/errorlog'
-if 'XDG_CONFIG_HOME' in environ and environ['XDG_CONFIG_HOME']:
-	DEFAULT_CONFDIR = environ['XDG_CONFIG_HOME'] + '/ranger'
-else:
-	DEFAULT_CONFDIR = '~/.config/ranger'
-DEBUG = ('-d' in argv or '--debug' in argv) and ('--' not in argv or
-	(('-d' in argv and argv.index('-d') < argv.index('--')) or
-	('--debug' in argv and argv.index('--debug') < argv.index('--'))))
-
-# Get some valid arguments before actually parsing them in main()
-#arg = OpenStruct(debug=DEBUG, clean=False, confdir=DEFAULT_CONFDIR,
-#		mode=0, flags='', targets=[])
-
-
-# Clean up
-del environ, OpenStruct, argv
+RANGERDIR = os.path.dirname(__file__)
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index c7ac3702..0ef0fc27 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -19,13 +19,21 @@ import os.path
 import sys
 from ranger import *
 
+LOGFILE = '/tmp/errorlog'
+
 def parse_arguments():
 	"""Parse the program arguments"""
 	from optparse import OptionParser, SUPPRESS_HELP
-	from ranger import __version__, USAGE, DEFAULT_CONFDIR
+	from ranger import __version__
 	from ranger.ext.openstruct import OpenStruct
 	from os.path import expanduser
 
+	if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
+		default_confdir = os.environ['XDG_CONFIG_HOME'] + '/ranger'
+	else:
+		default_confdir = '~/.config/ranger'
+	usage = '%prog [options] [path/filename]'
+
 	minor_version = __version__[2:]  # assumes major version number is <10
 	if '.' in minor_version:
 		minor_version = minor_version[:minor_version.find('.')]
@@ -35,7 +43,7 @@ def parse_arguments():
 	else:
 		version_string = 'ranger ' + __version__ + version_tag
 
-	parser = OptionParser(usage=USAGE, version=version_string)
+	parser = OptionParser(usage=usage, version=version_string)
 
 	parser.add_option('-d', '--debug', action='store_true',
 			help="activate debug mode")
@@ -47,7 +55,7 @@ def parse_arguments():
 			help="experimental: return the exit code 1 if ranger is" \
 					"used to run a file (with `ranger filename`)")
 	parser.add_option('-r', '--confdir', type='string',
-			metavar='dir', default=DEFAULT_CONFDIR,
+			metavar='dir', default=default_confdir,
 			help="the configuration directory. (%default)")
 	parser.add_option('-m', '--mode', type='int', default=0, metavar='n',
 			help="if a filename is supplied, run it with this mode")