summary refs log tree commit diff stats
path: root/ranger.py
Commit message (Collapse)AuthorAgeFilesLines
* Changed email address in source codehut2013-08-081-1/+1
| | | | | Since lavabit.com ceased providing email services, I had to change my address from hut lavabit com to hut lepus uberspace de.
* updated rest of the copyright noticeshut2013-02-221-1/+1
|
* update email address (romanz@lavabit.com -> hut@lavabit.com)hut2013-02-221-1/+1
|
* replaced tabs with 4 spaces in all python fileshut2013-02-101-3/+3
| | | | | | | | | PEP 8 (Style Guide for Python Code) suggests the use of 4 spaces: http://www.python.org/dev/peps/pep-0008/#indentation If you need to use tools like "git blame", you can use the -w option to ignore this commit entirely. Patches will continue to work if you substitute tabs with 4 spaces everywhere except in the Makefile.
* shorten all copyright messages for better readabilityhut2012-03-141-13/+1
|
* Updated copyright headershut2011-10-101-1/+1
| | | | As much as I hate this, it has to be done
* README: polished, removed INSTALLhut2011-10-051-5/+2
|
* ranger.py: made the argument optional in embedded bash scripthut2011-10-041-15/+16
|
* Fixed minor issue in ranger.pyhut2011-10-011-3/+3
|
* another correction of the bash wrapper scriptshut2011-09-281-1/+2
|
* shortened ranger.pyhut2011-09-281-6/+3
|
* sanitized bash wrapper scripts, reformulated BUGS section in manualhut2011-09-281-2/+2
|
* minor optimization in ranger.pyhut2011-09-281-6/+1
|
* improved bash wrappers in ranger.py and man pagehut2011-09-281-5/+7
|
* ranger.py: More reliable check for whether ./ranger.py is startedhut2011-05-071-1/+1
|
* ranger.py: minor change, more general exception handlinghut2011-04-051-1/+1
|
* improved ranger.pyhut2011-04-051-2/+10
|
* Polished ranger.pyhut2010-10-161-3/+3
|
* Small simplification of ranger.pyhut2010-09-291-3/+2
|
* Don't write any bytecode with --clean optionhut2010-09-291-0/+10
|
* ranger.py: Return 0 on success in embedded scripthut2010-09-221-1/+1
|
* simplify ranger.pyhut2010-09-221-25/+11
|
* ranger.py Fixed embedded shellscript (quotes for bash)hut2010-09-111-2/+2
|
* ranger.py: fixed escape in embedded shellscripthut2010-09-111-1/+1
|
* Changed default config dir to $XDG_CONFIG_HOME/rangerhut2010-08-281-1/+5
|
* main: catch SystemExit and return the exit valuehut2010-06-181-2/+3
|
* renamed "--fail-if-run" to the more accurate "--fail-unless-cd"hut2010-06-091-1/+1
| | | | The old name, --fail-if-run, is still valid and working.
* Reverted hashbang for ranger.py.hut2010-06-091-1/+1
| | | | | It causes an error here: /usr/bin/env: python -O: No such file or directory
* Changed hashbang line to "#!/usr/bin/env python"hut2010-06-091-1/+1
|
* Run python with flag "-O" by defaulthut2010-05-101-1/+1
| | | | | This will discard assert statements which are unnecessary for end users.
* Fixed bug #65 by adding flag "--fail-if-run"hut2010-04-261-1/+1
|
* ranger.py: removed whitespacehut2010-04-121-4/+0
|
* reverted a part of 45cf5174. Allow "source ranger ranger" againhut2010-04-011-8/+7
| | | | This is OK since it comes at almost no cost
* removed the cd-after-exit hackhut2010-03-291-13/+8
| | | | | | | | | Fear not. You still get the same functionality by using a function like: ranger() { $(which ranger) $@ && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" }
* ranger.__init__: don't implicitly import ranger.__main__hut2010-03-261-1/+1
|
* Changed license to the GNU General Public Licensehut2010-02-281-12/+14
|
* ranger.py: fixed cd-after-exit with spaces in directoryhut2010-02-241-1/+1
|
* ranger.py: removed unnecessary codehut2010-02-151-1/+1
|
* ranger.py: reverted cd-after-exit to the old wayhut2010-02-141-10/+1
| | | | | | | | This breaks cd-after-exit after Ctrl+C again, but enables compatibility with zsh which I prefer over the former. If you only use bash, you can safely revert this commit unless future changes make it break.
* ranger.py: more simple '--debug' flag checkhut2010-02-141-1/+1
|
* ranger.py: improved handling of bad importhut2010-01-261-1/+2
|
* ranger.py: more fixeshut2010-01-121-2/+2
|
* ranger.py: cleanup/fixhut2010-01-111-9/+8
|
* fixed #31, cd-after-exit works even after pressing ^Chut2010-01-111-1/+12
|
* added license informationhut2010-01-081-3/+17
|
* F1 key (inside console) for viewing information about the commandhut2009-12-291-1/+1
|
* shorten comment in ranger.pyhut2009-12-261-11/+5
|
* implemented OpenConsolehut2009-12-251-2/+2
|
* random updateshut2009-12-251-3/+16
|
* tons of stuffhut2009-12-171-1/+1
|
'>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
                                                            
 

                                           
                           

                                               


                                                
 

                                                      
                                              
 
               
                               
                                         
                                                          
                                        

                                                   

                                                     
                                                 
                                                                  
 
                                            
                         
                                                                                
                                        
                                  

                                           
                                                           
 


                                                                                       

                                                                                    

                                        

                                             




                                                                                 
                                      
                                
                                                 



                                                                                       
 
                                       
                                                
                                  
                
                                                   

                                                

                                                                  
 
                                        

                           
                                                                                 
                                                                                         







                                                        
                                        

                          










                                                                             

                                                                                                      

                                                       
 

                          
 
if __name__ == '__main__': from __init__ import init; init()

from os.path import realpath, join, dirname

from ranger import fsobject
from ranger.fsobject.file import File
from ranger.fsobject.directory import Directory
from ranger.shared.settings import SettingsAware

SettingsAware._setup()

TESTDIR = realpath(join(dirname(__file__), 'testdir'))
TESTFILE = join(TESTDIR, 'testfile5234148')
NONEXISTANT_DIR = join(TESTDIR, 'nonexistant')

import unittest
class Test1(unittest.TestCase):
	def test_initial_condition(self):
		# Check for the expected initial condition
		dir = Directory(TESTDIR)

		self.assertEqual(dir.path, TESTDIR)
		self.assertFalse(dir.content_loaded)
		self.assertEqual(dir.filenames, None)
		self.assertEqual(dir.files, None)
		self.assertRaises(fsobject.NotLoadedYet, len, dir)

	def test_after_content_loaded(self):
		import os
		# Check whether the directory has the correct list of filenames.
		dir = Directory(TESTDIR)
		dir.load_content()

		self.assertTrue(dir.exists)
		self.assertEqual(type(dir.filenames), list)

		# Get the filenames you expect it to have and sort both before
		# comparing. I don't expect any order after only loading the filenames.
		assumed_filenames = os.listdir(TESTDIR)
		assumed_filenames = list(map(lambda str: os.path.join(TESTDIR, str),
			assumed_filenames))
		assumed_filenames.sort()
		dir.filenames.sort()

		self.assertTrue(len(dir) > 0)
		self.assertEqual(dir.filenames, assumed_filenames)

		# build a file object for each file in the list assumed_filenames
		# and find exactly one equivalent in dir.files
		for name in assumed_filenames:
			f = File(name)
			f.load()
			for dirfile in dir.files:
				if (f.path == dirfile.path and f.stat == dirfile.stat):
					break
			else:
				self.fail("couldn't find file {0}".format(name))

	def test_nonexistant_dir(self):
		dir = Directory(NONEXISTANT_DIR)
		dir.load_content()
		
		self.assertTrue(dir.content_loaded)
		self.assertFalse(dir.exists)
		self.assertFalse(dir.accessible)
		self.assertEqual(dir.filenames, None)
		self.assertRaises(fsobject.NotLoadedYet, len, dir)

	def test_load_if_outdated(self):
		import os
		import time
		# modify the directory. If the time between the last modification
		# was within the filesystems resolution of mtime, we should have a reload

		def modify_dir():
			open(TESTFILE, 'w').close()
			os.unlink(TESTFILE)

		def mtime():
			return os.stat(TESTDIR).st_mtime

		dir = Directory(TESTDIR)
		dir.load()

		# If the modification happens to be in the same second as the
		# last modification, it will result in mtime having the same
		# integer value. So we wait until the resolution is exceeded
		# and mtime differs.
		old_mtime = mtime()
		for i in range(50):
			modify_dir()
			if old_mtime != mtime(): break
			time.sleep(0.1)
		else:
			# fail after 5 seconds of trying
			self.fail(
					"Cannot perform test: mtime of TESTDIR is not being updated.")

		self.assertTrue(dir.load_if_outdated())

if __name__ == '__main__':
	unittest.main()