summary refs log tree commit diff stats
path: root/ranger/ext
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-02-10 02:45:49 +0100
committerhut <hut@lepus.uberspace.de>2016-02-10 02:45:49 +0100
commit8099359508357ce5c0343275c311312633bfa611 (patch)
treebadbcb6a7588fa015cccfd5754c6e1deefc7c1cb /ranger/ext
parentfa4c3bbd9e33fde2727c5056c5f9d866a6227fe8 (diff)
downloadranger-8099359508357ce5c0343275c311312633bfa611.tar.gz
ext.rifle: fix line numbers in error messages
Diffstat (limited to 'ranger/ext')
-rwxr-xr-xranger/ext/rifle.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index c43de24f..afc0b558 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -154,8 +154,9 @@ class Rifle(object):
             config_file = self.config_file
         f = open(config_file, 'r')
         self.rules = []
-        lineno = 1
+        lineno = 0
         for line in f:
+            lineno += 1
             if line.startswith('#') or line == '\n':
                 continue
             line = line.strip()
@@ -170,7 +171,6 @@ class Rifle(object):
             except Exception as e:
                 self.hook_logger("Syntax error in %s line %d (%s)" % \
                     (config_file, lineno, str(e)))
-            lineno += 1
         f.close()
 
     def _eval_condition(self, condition, files, label):
href='/akspecs/ranger/blame/test/tc_ui.py?h=v1.8.1&id=4c05e43d11430fbfd8a5d86ae0070e24775251b1'>^
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














                                                                       





                                                          




                         
                                      






                                
                                                       


                                               
                                                         





                                         
 






















                                                                         
# 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/>.

import os.path
import sys
rangerpath = os.path.join(os.path.dirname(__file__), '..')
if sys.path[1] != rangerpath:
	sys.path[1:1] = [rangerpath]

import unittest
import curses

from ranger.gui import ui

from testlib import Fake, OK, raise_ok

ui.curses = Fake()

class Test(unittest.TestCase):
	def setUp(self):

		self.fm = Fake()
		self.ui = ui.UI(env=Fake(), fm=self.fm)

		def fakesetup():
			self.ui.widget = Fake()
			self.ui.add_child(self.ui.widget)
		self.ui.setup = fakesetup

		self.ui.initialize()

	def tearDown(self):
		self.ui.destroy()

	def test_passing(self):
		# Test whether certain method calls are passed to widgets
		widget = self.ui.widget

		widget.draw = raise_ok
		self.assertRaises(OK, self.ui.draw)
		widget.__clear__()

		widget.finalize = raise_ok
		self.assertRaises(OK, self.ui.finalize)
		widget.__clear__()

		widget.press = raise_ok
		random_key = 123
		self.assertRaises(OK, self.ui.handle_key, random_key)
		widget.__clear__()

		widget.destroy = raise_ok
		self.assertRaises(OK, self.ui.destroy)
		widget.__clear__()

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