summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-02 18:45:56 +0200
committerhut <hut@lavabit.com>2011-10-02 18:45:56 +0200
commitf7894a1583f82e1ba97d0aefcbc19cf1bf1fc936 (patch)
treeadd45f2405ce478c31b2906e588495be1bbf193a
parent2d199b547f5e23fbdfd0a3e24a623f5a4e792473 (diff)
downloadranger-f7894a1583f82e1ba97d0aefcbc19cf1bf1fc936.tar.gz
Changed version to 1.5.0
-rw-r--r--README2
-rw-r--r--doc/ranger.12
-rw-r--r--ranger/__init__.py2
-rw-r--r--ranger/core/helper.py11
4 files changed, 4 insertions, 13 deletions
diff --git a/README b/README
index 94aa19c6..e48edeb8 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Ranger v.1.4.4
+Ranger v.1.5.0
 ==============
 
 Ranger is a free console file manager that gives you greater flexibility
diff --git a/doc/ranger.1 b/doc/ranger.1
index 7bf94b41..fbda8fa1 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.4.3" "10/01/2011" "ranger manual"
+.TH RANGER 1 "ranger-1.5.0" "10/02/2011" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/__init__.py b/ranger/__init__.py
index 3d2633cd..32a31eae 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -29,7 +29,7 @@ from ranger.core.main import main
 
 # Information
 __license__ = 'GPL3'
-__version__ = '1.4.4'
+__version__ = '1.5.0'
 __author__ = __maintainer__ = 'Roman Zimbelmann'
 __email__ = 'romanz@lavabit.com'
 
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index d8081b01..090a475a 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -35,16 +35,7 @@ def parse_arguments():
 		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('.')]
-	version_tag = ' (stable)' if int(minor_version) % 2 == 0 else ' (testing)'
-	if __version__.endswith('.0'):
-		version_string = 'ranger ' + __version__[:-2] + version_tag
-	else:
-		version_string = 'ranger ' + __version__ + version_tag
-
-	parser = OptionParser(usage=usage, version=version_string)
+	parser = OptionParser(usage=usage, version='ranger '+__version__)
 
 	parser.add_option('-d', '--debug', action='store_true',
 			help="activate debug mode")
4
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


































































                                                                           









                                                               
                                                     
                                               

                                                  
 





                                                                                    





                                                                               

























                                                                                         
 

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

from ranger.ext.iter_tools import *

class TestCases(unittest.TestCase):
	def test_flatten(self):
		def f(x):
			return list(flatten(x))

		self.assertEqual(
			[1,2,3,4,5],
			f([1,2,3,4,5]))
		self.assertEqual(
			[1,2,3,4,5],
			f([1,[2,3],4,5]))
		self.assertEqual(
			[1,2,3,4,5],
			f([[1,[2,3]],4,5]))
		self.assertEqual(
			[],
			f([[[[]]]]))
		self.assertEqual(
			['a', 'b', 'fskldfjl'],
			f(['a', ('b', 'fskldfjl')]))
		self.assertEqual(
			['a', 'b', 'fskldfjl'],
			f(['a', deque(['b', 'fskldfjl'])]))
		self.assertEqual(
			set([3.5, 4.3, 5.2, 6.0]),
			set(f([6.0, set((3.5, 4.3)), (5.2, )])))

	def test_unique(self):
		def u(x):
			return list(unique(x))

		self.assertEqual(
			[1,2,3],
			u([1,2,3]))
		self.assertEqual(
			[1,2,3],
			u([1,2,3,2,1]))
		self.assertEqual(
			[1,2,3],
			u([1,2,3,1,2,3,2,2,3,1,2,3,1,2,3,2,3,2,1]))
		self.assertEqual(
			[1,[2,3]],
			u([1,[2,3],1,[2,3],[2,3],1,[2,3],1,[2,3],[2,3],1]))

	def test_unique_keeps_type(self):
		def u(x):
			return unique(x)

		self.assertEqual(
			[1,2,3],
			u([1,2,3,1]))
		self.assertEqual(
			(1,2,3),
			u((1,2,3,1)))
		self.assertEqual(
			set((1,2,3)),
			u(set((1,2,3,1))))
		self.assertEqual(
			deque((1,2,3)),
			u(deque((1,2,3,1))))

	def test_mount_path(self):
		# assuming ismount() is used

		def my_ismount(path):
			depth = path.count('/')
			if path.startswith('/media'):
				return depth == 0 or depth == 2
			return depth <= 1

		from ranger.ext import mount_path
		original_ismount = mount_path.ismount
		mount_path.ismount = my_ismount
		try:
			mp = mount_path.mount_path

			self.assertEqual('/home', mp('/home/hut/porn/bondage'))
			self.assertEqual('/', mp('/'))
			self.assertEqual('/media/sdb1', mp('/media/sdb1/foo/bar'))
			self.assertEqual('/media/sdc2', mp('/media/sdc2/a/b/c/d/e'))
		finally:
			mount_path.ismount = original_ismount

		# TODO: links are not tested but I don't see how its possible
		# without messing around with mounts.
		# self.assertEqual('/media/foo',
		#     mount_path('/media/bar/some_link_to_a_foo_subdirectory'))

	def test_openstruct(self):
		from ranger.ext.openstruct import OpenStruct
		from random import randint, choice
		from string import ascii_letters

		os = OpenStruct(a='a')
		self.assertEqual(os.a, 'a')
		self.assertRaises(AttributeError, getattr, os, 'b')

		dictionary = {'foo': 'bar', 'zoo': 'zar'}
		os = OpenStruct(dictionary)
		self.assertEqual(os.foo, 'bar')
		self.assertEqual(os.zoo, 'zar')
		self.assertRaises(AttributeError, getattr, os, 'sdklfj')

		for i in range(100):
			attr_name = ''.join(choice(ascii_letters) \
				for x in range(randint(3,9)))
			value = randint(100,999)
			if not attr_name in os:
				self.assertRaises(AttributeError, getattr, os, attr_name)
			setattr(os, attr_name, value)
			value2 = randint(100,999)
			setattr(os, attr_name, value2)
			self.assertEqual(value2, getattr(os, attr_name))


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