summary refs log tree commit diff stats
path: root/uml/141058.diagram
blob: 9268c4c414447cc60f12d48c0d50c20500033153 (plain) (blame)
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
format 70

classinstance 128258 class_ref 169218 // Main
  name ""   xyz 64 4 2000 life_line_z 2000
classinstance 128386 class_ref 149378 // FM
  name ""   xyz 185 32 2000 life_line_z 2000
classinstance 128898 class_ref 128258 // DefaultUI
  name ""   mortal  xyz 289 80 2000 life_line_z 2000
classinstance 132226 class_ref 149122 // Environment
  name ""   xyz 421 84 2000 life_line_z 2000
classinstance 133122 class_ref 156034 // Widget
  name ""   xyz 544 107 2000 life_line_z 2000
classinstance 133762 class_ref 149250 // curses
  name ""   xyz 632 4 2000 life_line_z 2000
classinstance 134530 class_ref 148866 // Command
  name ""   xyz 727 4 2000 life_line_z 2000
durationcanvas 128514 classinstance_ref 128258 // :Main
  xyzwh 83 82 2010 11 40
end
durationcanvas 128642 classinstance_ref 128386 // :FM
  xyzwh 204 82 2010 11 25
end
durationcanvas 129026 classinstance_ref 128258 // :Main
  xyzwh 83 130 2010 11 34
end
durationcanvas 129154 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 130 2010 11 58
  overlappingdurationcanvas 135426
    xyzwh 331 142 2020 11 40
    overlappingdurationcanvas 135682
      xyzwh 337 151 2030 11 25
    end
  end
end
durationcanvas 129410 classinstance_ref 128258 // :Main
  xyzwh 83 180 2010 11 35
end
durationcanvas 129538 classinstance_ref 128386 // :FM
  xyzwh 204 172 2010 11 468
  overlappingdurationcanvas 136450
    xyzwh 210 537 2020 11 25
  end
end
durationcanvas 129794 classinstance_ref 128258 // :Main
  xyzwh 83 655 2010 11 27
end
durationcanvas 129922 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 655 2010 11 27
end
durationcanvas 130178 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 265 2010 11 26
end
durationcanvas 130434 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 311 2010 11 26
end
durationcanvas 130690 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 381 2010 11 43
end
durationcanvas 131074 classinstance_ref 128898 // :DefaultUI
  xyzwh 325 467 2010 11 53
  overlappingdurationcanvas 134914
    xyzwh 331 489 2020 11 25
  end
end
durationcanvas 132354 classinstance_ref 132226 // :Environment
  xyzwh 469 606 2010 11 32
end
durationcanvas 132866 classinstance_ref 132226 // :Environment
  xyzwh 469 184 2010 11 27
end
durationcanvas 133250 classinstance_ref 133122 // :Widget
  xyzwh 571 280 2010 11 25
end
durationcanvas 133506 classinstance_ref 133122 // :Widget
  xyzwh 571 323 2010 11 25
end
durationcanvas 133890 classinstance_ref 133762 // :curses
  xyzwh 658 389 2010 11 31
end
durationcanvas 135170 classinstance_ref 133122 // :Widget
  xyzwh 571 501 2010 11 27
end
durationcanvas 135938 classinstance_ref 134530 // :Command
  xyzwh 767 506 2010 11 72
end
durationcanvas 136706 classinstance_ref 133122 // :Widget
  xyzwh 571 563 2010 11 34
end
msg 128770 synchronous
  from durationcanvas_ref 128514
  to durationcanvas_ref 128642
  yz 82 2015 msg operation_ref 141826 // "initialize()"
  show_full_operations_definition default drawing_language default
  label_xy 117 64
msg 129282 synchronous
  from durationcanvas_ref 129026
  to durationcanvas_ref 129154
  yz 130 2015 msg operation_ref 171138 // "initialize()"
  show_full_operations_definition default drawing_language default
  label_xy 124 111
msg 129666 synchronous
  from durationcanvas_ref 129410
  to durationcanvas_ref 129538
  yz 180 2015 msg operation_ref 141954 // "loop()"
  show_full_operations_definition default drawing_language default
  label_xy 129 162
msg 130050 synchronous
  from durationcanvas_ref 129794
  to durationcanvas_ref 129922
  yz 655 2015 msg operation_ref 134914 // "destroy()"
  show_full_operations_definition default drawing_language default
  label_xy 119 636
msg 130306 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 130178
  yz 265 2015 msg operation_ref 134530 // "draw()"
  show_full_operations_definition default drawing_language default
  label_xy 245 247
msg 130562 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 130434
  yz 311 2015 msg operation_ref 149378 // "finalize()"
  show_full_operations_definition default drawing_language default
  label_xy 240 293
msg 130818 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 130690
  yz 382 2015 msg operation_ref 148738 // "get_next_key()"
  show_full_operations_definition default drawing_language default
  label_xy 229 361
msg 130946 return
  from durationcanvas_ref 130690
  to durationcanvas_ref 129538
  yz 412 2020 unspecifiedmsg
  show_full_operations_definition default drawing_language default
msg 131202 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 131074
  yz 467 2015 msg operation_ref 148610 // "handle_key()"
  show_full_operations_definition default drawing_language default
  label_xy 234 449
msg 132482 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 132354
  yz 606 2015 msg operation_ref 171522 // "garbage_collect()"
  show_full_operations_definition default drawing_language default
  label_xy 260 587
msg 132994 synchronous
  from durationcanvas_ref 129538
  to durationcanvas_ref 132866
  yz 185 2020 msg operation_ref 171650 // "enter_dir()"
  show_full_operations_definition default drawing_language default
  label_xy 222 164
msg 133378 synchronous
  from durationcanvas_ref 130178
  to durationcanvas_ref 133250
  yz 280 2015 msg operation_ref 134530 // "draw()"
  show_full_operations_definition default drawing_language default
  label_xy 407 262
msg 133634 synchronous
  from durationcanvas_ref 130434
  to durationcanvas_ref 133506
  yz 323 2015 msg operation_ref 149378 // "finalize()"
  show_full_operations_definition default drawing_language default
  label_xy 405 303
msg 134018 synchronous
  from durationcanvas_ref 130690
  to durationcanvas_ref 133890
  yz 391 2015 msg operation_ref 171778 // "getch()"
  show_full_operations_definition default drawing_language default
  label_xy 713 361
msg 134402 return
  from durationcanvas_ref 133890
  to durationcanvas_ref 130690
  yz 408 2020 unspecifiedmsg
  show_full_operations_definition default drawing_language default
reflexivemsg 135042 synchronous
  to durationcanvas_ref 134914
  yz 489 2025 msg operation_ref 148482 // "handle_mouse()"
  show_full_operations_definition default drawing_language default
  label_xy 345 462
msg 135298 synchronous
  from durationcanvas_ref 134914
  to durationcanvas_ref 135170
  yz 502 2030 msg operation_ref 134786 // "click()"
  show_full_operations_definition default drawing_language default
  label_xy 474 484
reflexivemsg 135554 synchronous
  to durationcanvas_ref 135426
  yz 142 2025 msg operation_ref 148866 // "setup()"
  show_full_operations_definition default drawing_language default
  label_xy 340 120
reflexivemsg 135810 synchronous
  to durationcanvas_ref 135682
  yz 151 2035 msg operation_ref 149890 // "add_obj()"
  show_full_operations_definition default drawing_language default
  label_xy 372 143
msg 136066 synchronous
  from durationcanvas_ref 135170
  to durationcanvas_ref 135938
  yz 506 2015 msg operation_ref 164226 // "execute()"
  show_full_operations_definition default drawing_language default
  label_xy 593 488
msg 136578 synchronous
  from durationcanvas_ref 135938
  to durationcanvas_ref 136450
  yz 537 2025 explicitmsg "<command>"
  show_full_operations_definition default drawing_language default
  label_xy 222 520
msg 136834 synchronous
  from durationcanvas_ref 135938
  to durationcanvas_ref 136706
  yz 567 2030 explicitmsg "<command>"
  show_full_operations_definition default drawing_language default
  label_xy 581 554
end
03 20:25:01 +0100 mime type support, integrated into colorschemes' href='/akspecs/ranger/commit/ranger/fsobject.py?id=b810fe28876d750495ac05d9993ce02afb561c01'>b810fe28 ^
9b83f114 ^


8f2f1767 ^


d906b0dd ^
8f2f1767 ^

a44749f6 ^


94bfe914 ^
f623ef5b ^
94bfe914 ^



a44749f6 ^

9506fb8e ^
3de15ddd ^
9506fb8e ^
fae694a0 ^
871c502d ^
4fc56903 ^
ea87d005 ^
b810fe28 ^
3de15ddd ^
4ffef98c ^


b810fe28 ^
4ffef98c ^


b810fe28 ^
90f204e3 ^
b810fe28 ^


4ffef98c ^
b810fe28 ^
4ffef98c ^

















ea87d005 ^
3201b163 ^


ea87d005 ^
3201b163 ^

99e6cf47 ^
b810fe28 ^
fae694a0 ^
ec5dfcb1 ^

b4b0eb24 ^

b810fe28 ^

3566114b ^
863f85ce ^


3566114b ^
863f85ce ^



3566114b ^
30b25795 ^
3566114b ^
863f85ce ^



3566114b ^

3566114b ^

863f85ce ^

fae694a0 ^
863f85ce ^




3566114b ^
863f85ce ^

3566114b ^


863f85ce ^
db426717 ^



9506fb8e ^
3566114b ^

863f85ce ^































30b25795 ^
cfdbb9d6 ^



863f85ce ^
4fb1670e ^
863f85ce ^
4fb1670e ^


cfdbb9d6 ^
863f85ce ^

6c34428d ^
863f85ce ^


cfdbb9d6 ^
e74ac575 ^
298c72a2 ^
cfdbb9d6 ^
4fb1670e ^

fae694a0 ^
fae694a0 ^
ec5dfcb1 ^

b4b0eb24 ^

863f85ce ^

50d31c9d ^
c2a89082 ^
863f85ce ^
c2a89082 ^
ec5dfcb1 ^
c1a50251 ^
fae694a0 ^

fae694a0 ^
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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
                                                                 
 



                                                                      
 






                                                                       
 


                                                                             
 
                                                     
                     
                                                                          
                      
                                                         
                                                
                                  
                                                    
 
                                                        






                                

                    
                            
























                              
 
                           

                
 
                                                                  
                                            
 

                                            
                                
                                              
                                                           
                                                                                  
                                            
                                         
                                      
 
                    

                                                                        

                                             
 


                                                                             


                                                        
                                                                                  

                                                   


                                          
                            
                                                                                      



                                                    

                                     
                          
                                                                   
                                     
 
                      
                                                                        
 
                               
                                                                                    


                                                                                   
 


                                                               
                                                                   
                                                                 


                                                                                    
                                                                                       
 

















                                                   
 


                                                                
 

                                                                           
                                           
 
                       

                                                                             

                                                      

                                  
 


                                                                          
                                



                                                                           
                                           
                     
                            



                                                                                   

                                    

                                     

                                               
                                              




                                                                      
                                                  

                                                                                 


                                                     
                                   



                                                                                            
                     

                                               































                                                                                 
 



                                                
                                     
                                     
                                  


                                     
 

                                        
                                                                      


                                                          
                                     
                                                         
                                          
 

                                                 
 
                                   

                                                                            

                               

                                   
                                   
                    
                                                              
                               
                                         
                                                                     

                                   
                            
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

CONTAINER_EXTENSIONS = ('7z', 'ace', 'ar', 'arc', 'bz', 'bz2', 'cab', 'cpio',
	'cpt', 'dgc', 'dmg', 'gz', 'iso', 'jar', 'msi', 'pkg', 'rar', 'shar',
	'tar', 'tbz', 'tgz', 'xar', 'xz', 'zip')

from os import access, listdir, lstat, readlink, stat
from time import time
from os.path import abspath, basename, dirname, realpath, splitext, extsep
from . import BAD_INFO
from ranger.shared import MimeTypeAware, FileManagerAware
from ranger.ext.shell_escape import shell_escape
from ranger.ext.spawn import spawn
from ranger.ext.human_readable import human_readable

class FileSystemObject(MimeTypeAware, FileManagerAware):
	(_filetype,
	_shell_escaped_basename,
	basename,
	basename_lower,
	dirname,
	extension,
	infostring,
	path,
	permissions,
	stat) = (None,) * 10

	(content_loaded,
	force_load,

	is_device,
	is_directory,
	is_file,
	is_fifo,
	is_link,
	is_socket,

	accessible,
	exists,
	loaded,
	marked,
	runnable,
	stopped,
	tagged,

	audio,
	container,
	document,
	image,
	media,
	video) = (False,) * 21

	mimetype_tuple = ()
	size = 0


	def __init__(self, path, preload=None, path_is_abs=False):
		MimeTypeAware.__init__(self)

		if not path_is_abs:
			path = abspath(path)
		self.path = path
		self.basename = basename(path)
		self.basename_lower = self.basename.lower()
		self.extension = splitext(self.basename)[1].lstrip(extsep) or None
		self.dirname = dirname(path)
		self.realpath = self.path
		self.preload = preload

		try:
			lastdot = self.basename.rindex('.') + 1
			self.extension = self.basename[lastdot:].lower()
		except ValueError:
			self.extension = None

	def __repr__(self):
		return "<{0} {1}>".format(self.__class__.__name__, self.path)

	@property
	def shell_escaped_basename(self):
		if self._shell_escaped_basename is None:
			self._shell_escaped_basename = shell_escape(self.basename)
		return self._shell_escaped_basename

	@property
	def filetype(self):
		if self._filetype is None:
			try:
				got = spawn(["file", '-Lb', '--mime-type', self.path])
			except OSError:
				self._filetype = ''
			else:
				self._filetype = got
		return self._filetype

	def __str__(self):
		"""returns a string containing the absolute path"""
		return str(self.path)

	def use(self):
		"""Used in garbage-collecting.  Override in Directory"""

	def set_mimetype(self):
		"""assign attributes such as self.video according to the mimetype"""
		self._mimetype = self.mimetypes.guess_type(self.basename, False)[0]
		if self._mimetype is None:
			self._mimetype = ''

		self.video = self._mimetype.startswith('video')
		self.image = self._mimetype.startswith('image')
		self.audio = self._mimetype.startswith('audio')
		self.media = self.video or self.image or self.audio
		self.document = self._mimetype.startswith('text')
		self.container = self.extension in CONTAINER_EXTENSIONS

		keys = ('video', 'audio', 'image', 'media', 'document', 'container')
		self._mimetype_tuple = tuple(key for key in keys if getattr(self, key))

		if self._mimetype == '':
			self._mimetype = None

	@property
	def mimetype(self):
		try:
			return self._mimetype
		except:
			self.set_mimetype()
			return self._mimetype

	@property
	def mimetype_tuple(self):
		try:
			return self._mimetype_tuple
		except:
			self.set_mimetype()
			return self._mimetype_tuple

	def mark(self, boolean):
		directory = self.env.get_directory(self.dirname)
		directory.mark_item(self)

	def _mark(self, boolean):
		"""Called by directory.mark_item() and similar functions"""
		self.marked = bool(boolean)

	def load(self):
		"""
		reads useful information about the filesystem-object from the
		filesystem and caches it for later use
		"""

		self.loaded = True

		# Get the stat object, either from preload or from [l]stat
		new_stat = None
		path = self.path
		if self.preload:
			new_stat = self.preload[1]
			is_link = (new_stat.st_mode & 0o120000) == 0o120000
			if is_link:
				new_stat = self.preload[0]
			self.preload = None
		else:
			try:
				new_stat = lstat(path)
				is_link = (new_stat.st_mode & 0o120000) == 0o120000
				if is_link:
					new_stat = stat(path)
			except:
				pass

		# Set some attributes
		if new_stat:
			mode = new_stat.st_mode
			self.accessible = True
			self.is_device = (mode & 0o060000) == 0o060000
			self.is_fifo = (mode & 0o010000) == 0o010000
			self.is_link = is_link
			self.is_socket = (mode & 0o140000) == 0o140000
			if access(path, 0):
				self.exists = True
				if self.is_directory:
					self.runnable = (mode & 0o0100) == 0o0100
			else:
				self.exists = False
				self.runnable = False
			if is_link:
				try:
					self.realpath = realpath(path)
				except OSError:
					pass  # it is impossible to get the link destination
		else:
			self.accessible = False

		# Determine infostring
		if self.is_file:
			if new_stat:
				self.size = new_stat.st_size
				self.infostring = ' ' + human_readable(self.size)
			else:
				self.size = 0
				self.infostring = '?'
		elif self.is_directory:
			try:
				self.size = len(listdir(path))  # bite me
			except OSError:
				self.size = 0
				self.infostring = '?'
				self.accessible = False
			else:
				self.infostring = ' %d' % self.size
				self.accessible = True
				self.runnable = True
		elif self.is_device:
			self.size = 0
			self.infostring = 'dev'
		elif self.is_fifo:
			self.size = 0
			self.infostring = 'fifo'
		elif self.is_socket:
			self.size = 0
			self.infostring = 'sock'
		if self.is_link:
			self.infostring = '->' + self.infostring

		self.stat = new_stat

	def get_permission_string(self):
		if self.permissions is not None:
			return self.permissions

		if self.is_directory:
			perms = ['d']
		elif self.is_link:
			perms = ['l']
		else:
			perms = ['-']

		mode = self.stat.st_mode
		test = 0o0400
		while test:  # will run 3 times because 0o400 >> 9 = 0
			for what in "rwx":
				if mode & test:
					perms.append(what)
				else:
					perms.append('-')
				test >>= 1

		self.permissions = ''.join(perms)
		return self.permissions

	def load_if_outdated(self):
		"""
		Calls load() if the currently cached information is outdated
		or nonexistant.
		"""
		if not self.loaded:
			self.load()
			return True
		try:
			real_mtime = lstat(self.path).st_mtime
		except OSError:
			real_mtime = None
		if not self.stat or self.stat.st_mtime != real_mtime:
			self.load()
			return True
		return False