summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-02 00:07:12 +0100
committerhut <hut@lavabit.com>2010-01-02 00:07:12 +0100
commit2ca2e862e616eba862ac80f5ee0003d1aa984a32 (patch)
treeedf54b867a5df7f5935f5e2738777e28a55ac99a
parent811f5bb82769413e5f9b389f92218d05cbe1597e (diff)
downloadranger-2ca2e862e616eba862ac80f5ee0003d1aa984a32.tar.gz
cleanups
-rw-r--r--ranger/commands.py1
-rw-r--r--ranger/defaults/keys.py4
-rw-r--r--ranger/fsobject/directory.py3
-rw-r--r--ranger/fsobject/loader.py1
-rw-r--r--ranger/gui/displayable.py1
-rw-r--r--ranger/gui/widgets/browsercolumn.py1
-rw-r--r--ranger/keyapi.py1
7 files changed, 1 insertions, 11 deletions
diff --git a/ranger/commands.py b/ranger/commands.py
index 95dfaf99..09e9a766 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -2,7 +2,6 @@ import os
 from ranger.shared import FileManagerAware
 from ranger.gui.widgets import console_mode as cmode
 from ranger.ext.command_parser import LazyParser as parse
-from ranger import log
 
 class Command(FileManagerAware):
 	"""Abstract command class"""
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 46d71af6..5f7691e2 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -142,10 +142,6 @@ def initialize_commands(command_list):
 	bind('!', fm.open_console(cmode.OPEN))
 	bind('r', fm.open_console(cmode.OPEN_QUICK))
 
-	def test(arg):
-		arg.fm.notify(str(arg.n))
-	bind('x', test)
-
 	# definitions which require their own function:
 	def ggG(default):
 		# moves to an absolute point, or to a predefined default
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 5ff768fb..9b42e3c6 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -2,7 +2,6 @@ from ranger.fsobject import BAD_INFO, File, FileSystemObject
 from ranger.shared import SettingsAware
 from ranger.ext.accumulator import Accumulator
 from collections import deque
-from ranger import log
 import ranger.fsobject
 
 def sort_by_basename(path):
@@ -113,7 +112,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 		in each iteration.
 		"""
 
-#		log("generating loader for " + self.path + "(" + str(id(self)) + ")")
+		# log("generating loader for " + self.path + "(" + str(id(self)) + ")")
 		from os.path import join, isdir, basename
 		from os import listdir
 
diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py
index a67c75fb..674af1f3 100644
--- a/ranger/fsobject/loader.py
+++ b/ranger/fsobject/loader.py
@@ -1,6 +1,5 @@
 from collections import deque
 from time import time
-from ranger import log
 from ranger.shared import FileManagerAware
 import math
 
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 838de3fb..bace4e0c 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -1,6 +1,5 @@
 from ranger.shared import FileManagerAware, EnvironmentAware
 from ranger.gui.curses_shortcuts import CursesShortcuts
-from ranger import log
 import _curses
 
 
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 6ab49c62..cca9e1f6 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -1,7 +1,6 @@
 """The BrowserColumn widget displays the contents of a directory or file."""
 from . import Widget
 from .pager import Pager
-from ranger import log
 
 class BrowserColumn(Pager, Widget):
 	main_column = False
diff --git a/ranger/keyapi.py b/ranger/keyapi.py
index 56552584..82f1495d 100644
--- a/ranger/keyapi.py
+++ b/ranger/keyapi.py
@@ -3,7 +3,6 @@ from curses.ascii import *
 from ranger import RANGERDIR
 from ranger.gui.widgets import console_mode as cmode
 from ranger.container.bookmarks import ALLOWED_KEYS as ALLOWED_BOOKMARK_KEYS
-from ranger import log
 
 def make_abbreviations(command_list):
 	def bind(*args):
01-01 04:22:32 +0100 improved procedures of spawning processes' href='/akspecs/ranger/commit/ranger/defaults/apps.py?h=v1.9.2&id=23236d0cfd081305a8fd93428ab842d7814df380'>23236d0c ^
cc952d63 ^
23236d0c ^


cc952d63 ^
d46a05a8 ^
23236d0c ^

cc952d63 ^
d46a05a8 ^
1b0786f2 ^



d46a05a8 ^
1b0786f2 ^





d46a05a8 ^

845bd407 ^




d46a05a8 ^
23236d0c ^


cc952d63 ^
23236d0c ^
d46a05a8 ^
23236d0c ^


cc952d63 ^
23236d0c ^

871c502d ^
cc952d63 ^
23236d0c ^

d46a05a8 ^
23236d0c ^










d46a05a8 ^
23236d0c ^




ea87d005 ^
d46a05a8 ^
ac0daa33 ^
23236d0c ^
ac0daa33 ^
845bd407 ^
d46a05a8 ^
845bd407 ^






ea87d005 ^
c3cdeb9c ^


ea87d005 ^
c3cdeb9c ^


ea87d005 ^
d46a05a8 ^
845bd407 ^
c3cdeb9c ^
845bd407 ^
d46a05a8 ^
845bd407 ^

ea87d005 ^
d46a05a8 ^
845bd407 ^






ea87d005 ^
d46a05a8 ^
845bd407 ^
8e1de917 ^
ea87d005 ^
d46a05a8 ^
845bd407 ^

ea87d005 ^
d46a05a8 ^
845bd407 ^
8e1de917 ^
845bd407 ^
d46a05a8 ^
845bd407 ^




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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174













                                                                          
         
                               
                                 
 




                                           
                                       


                                                               
 

                                                  
                                                                        

                                                                                   


                                                         


                                                                   

                               
                                                  


                                      
                                              
                                                                 
 
                           
                                              

                              
                                                 
 


                                                                           
 
                          

                                     
 
                                



                                                             
                     





                                                              

                                                      




                                               
                              


                                                 
 
                                 
                                                                            


                                                                                            
 

                                                                       
 
                     

                                                        
                          










                                                                         
                              




                                                                
 
                            
                               
                              
                                       
 
                           






                                                     
 


                                        
 


                                       
 
                              
                                 
                                         
 
                            

                                       
 
                           






                                                                         
 
                            
                               
                                                
 
                             

                                        
 
                           
                              
                                               
 
                            




                                                               
# Copyright (c) 2009, 2010 hut <hut@lavabit.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import os
from re import compile, VERBOSE
from ranger.applications import *

INTERPRETED_LANGUAGES = compile(r'''
	^(text|application)\/x-(
		haskell|perl|python|ruby|sh
	)$''', VERBOSE)

class CustomApplications(Applications):
	def app_default(self, c):
		"""How to determine the default application?"""
		f = c.file

		if f.extension is not None:
			if f.extension in ('pdf'):
				return self.either(c, 'apvlv', 'evince')
			if f.extension in ('html', 'htm', 'xhtml', 'swf'):
				return self.either(c, 'firefox', 'opera', 'elinks')
			if f.extension in ('swc', 'smc'):
				return self.app_zsnes(c)

		if f.mimetype is not None:
			if INTERPRETED_LANGUAGES.match(f.mimetype):
				return self.app_edit_or_run(c)

		if f.container:
			return self.app_aunpack(c)

		if f.video or f.audio:
			if f.video:
				c.flags += 'd'
			return self.either(c, 'mplayer', 'totem')

		if f.image:
			return self.app_feh(c)

		if f.document:
			return self.app_editor(c)

	# ----------------------------------------- application definitions
	def app_pager(self, c):
		return tup('less', *c)

	@depends_on('vim')
	def app_vim(self, c):
		return tup('vim', *c)

	def app_editor(self, c):
		try:
			default_editor = os.environ['EDITOR']
		except KeyError:
			pass
		else:
			parts = default_editor.split()
			exe_name = os.path.basename(parts[0])
			if exe_name in self.fm.executables:
				return tuple(parts) + tuple(c)

		return self.either(c, 'vim', 'emacs', 'nano')

	@depends_on(app_editor, Applications.app_self)
	def app_edit_or_run(self, c):
		if c.mode is 1:
			return self.app_self(c)
		return self.app_editor(c)

	@depends_on('mplayer')
	def app_mplayer(self, c):
		if c.mode is 1:
			return tup('mplayer', *c)

		elif c.mode is 2:
			args = "mplayer -fs -sid 0 -vfm ffmpeg -lavdopts " \
					"lowres=1:fast:skiploopfilter=all:threads=8".split()
			args.extend(c)
			return tup(*args)

		elif c.mode is 3:
			return tup('mplayer', '-mixer', 'software', *c)

		else:
			return tup('mplayer', '-fs', *c)

	@depends_on('feh')
	def app_feh(self, c):
		arg = {1: '--bg-scale', 2: '--bg-tile', 3: '--bg-center'}

		c.flags += 'd'

		if c.mode in arg:
			return tup('feh', arg[c.mode], c.file.path)
		if c.mode is 4:
			return tup('gimp', *c)
		return tup('feh', *c)

	@depends_on('aunpack')
	def app_aunpack(self, c):
		if c.mode is 0:
			c.flags += 'p'
			return tup('aunpack', '-l', c.file.path)
		return tup('aunpack', c.file.path)

	@depends_on('apvlv')
	def app_apvlv(self, c):
		c.flags += 'd'
		return tup('apvlv', *c)

	@depends_on('make')
	def app_make(self, c):
		if c.mode is 0:
			return tup("make")
		if c.mode is 1:
			return tup("make", "install")
		if c.mode is 2:
			return tup("make", "clear")

	@depends_on('elinks')
	def app_elinks(self, c):
		return tup('elinks', *c)

	@depends_on('opera')
	def app_elinks(self, c):
		return tup('opera', *c)

	@depends_on('firefox')
	def app_firefox(self, c):
		return tup("firefox", *c)

	@depends_on('javac')
	def app_javac(self, c):
		return tup("javac", *c)

	@depends_on('java')
	def app_java(self, c):
		def strip_extensions(file):
			if '.' in file.basename:
				return file.path[:file.path.index('.')]
			return file.path
		files_without_extensions = map(strip_extensions, c.files)
		return tup("java", files_without_extensions)

	@depends_on('zsnes')
	def app_zsnes(self, c):
		return tup("zsnes", c.file.path)

	@depends_on('evince')
	def app_evince(self, c):
		return tup("evince", *c)

	@depends_on('wine')
	def app_wine(self, c):
		return tup("wine", c.file.path)

	@depends_on('totem')
	def app_totem(self, c):
		if c.mode is 0:
			return tup("totem", "--fullscreen", *c)
		if c.mode is 1:
			return tup("totem", *c)