summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-09-22 00:39:07 +0200
committerhut <hut@lavabit.com>2010-09-22 00:39:07 +0200
commitcba63cf3683d4ca532efd179005e2ac1f6c60e38 (patch)
tree8e73659cff1e51b8ac102d1f55866f8fa358e64c /ranger.py
parente07d8b03612ede6ae75947d0d8ba71346aa894e1 (diff)
downloadranger-cba63cf3683d4ca532efd179005e2ac1f6c60e38.tar.gz
simplify ranger.py
Diffstat (limited to 'ranger.py')
-rwxr-xr-xranger.py36
1 files changed, 11 insertions, 25 deletions
diff --git a/ranger.py b/ranger.py
index 5652ba69..abe4f5e8 100755
--- a/ranger.py
+++ b/ranger.py
@@ -16,17 +16,16 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# ----------------------------------------------------------------------------
-#
-# An embedded shell script. It allows you to change the directory
-# after you exit ranger by starting it with: source ranger ranger
+
+# Embed a script which allows you to change the directory of the parent shell
+# after you exit ranger.  Run it with the command: source ranger ranger
 """":
 if [ $1 ]; then
+	$@ --fail-unless-cd &&
 	if [ -z "$XDG_CONFIG_HOME" ]; then
-		"$@" --fail-unless-cd && cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
+		cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
 	else
-		"$@" --fail-unless-cd && cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
+		cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
 	fi
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
@@ -34,23 +33,10 @@ fi
 return 1
 """
 
-import sys
-
-# Redefine the docstring, since the previous one was hijacked to
-# embed a shellscript.
+# Set the actual docstring
 __doc__ = """Ranger - file browser for the unix terminal"""
 
-# Importing the main method may fail if the ranger directory
-# is neither in the same directory as this file, nor in one of
-# pythons global import paths.
-try:
-	from ranger.__main__ import main
-except ImportError:
-	if '-d' not in sys.argv and '--debug' not in sys.argv:
-		print("Can't import the main module.")
-		print("To run an uninstalled copy of ranger,")
-		print("launch ranger.py in the top directory.")
-	else:
-		raise
-else:
-	sys.exit(main())
+# Start ranger
+import ranger.__main__
+exit_code = ranger.__main__.main() 
+raise SystemExit(exit_code)
#n207'>207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328