about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2015-05-08 10:16:10 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2015-05-08 10:16:10 +0200
commitdff0e71b2aa0c4f74816db0ffdd0c662836652cf (patch)
treecb066f4ecab178c91f202b893ed2a36e9848b5d3
parentfa7cb5b8145d005286312ca69da9d254683b5ea7 (diff)
downloadranger-dff0e71b2aa0c4f74816db0ffdd0c662836652cf.tar.gz
Replaced file.basename with file.relative_path where appropriate.
The usage of file.basename could lead to some issues with :flat.
-rw-r--r--examples/plugin_linemode.py2
-rw-r--r--examples/rc_emacs.conf4
-rw-r--r--ranger/config/commands.py18
-rw-r--r--ranger/config/rc.conf4
-rw-r--r--ranger/container/directory.py6
-rw-r--r--ranger/container/fsobject.py9
-rw-r--r--ranger/core/linemode.py2
7 files changed, 23 insertions, 22 deletions
diff --git a/examples/plugin_linemode.py b/examples/plugin_linemode.py
index e4513f5d..8a92552e 100644
--- a/examples/plugin_linemode.py
+++ b/examples/plugin_linemode.py
@@ -13,4 +13,4 @@ from ranger.core.linemode import LinemodeBase
 class MyLinemode(LinemodeBase):
     name = "rot13"
     def filetitle(self, file, metadata):
-        return codecs.encode(file.basename, "rot_13")
+        return codecs.encode(file.relative_path, "rot_13")
diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf
index aab083f4..e8b76ff2 100644
--- a/examples/rc_emacs.conf
+++ b/examples/rc_emacs.conf
@@ -318,8 +318,8 @@ map <C-x>wn shell -f echo -n %f    | xsel -i; xsel -o | xsel -i -b
 map <C-x>= chmod
 
 map <A-d>  console rename%space
-map <C-e>  eval fm.open_console('rename ' + fm.thisfile.basename)
-map <C-a>  eval fm.open_console('rename ' + fm.thisfile.basename, position=7)
+map <C-e>  eval fm.open_console('rename ' + fm.thisfile.relative_path)
+map <C-a>  eval fm.open_console('rename ' + fm.thisfile.relative_path, position=7)
 
 map <C-y>y  paste
 map <C-y>o  paste overwrite=True
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index cb62a62b..acc98457 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -520,7 +520,7 @@ class delete(Command):
 
         if confirm != 'never' and (confirm != 'multiple' or many_files):
             self.fm.ui.console.ask("Confirm deletion of: %s (y/N)" %
-                ', '.join(f.basename for f in self.fm.thistab.get_selection()),
+                ', '.join(f.relative_path for f in self.fm.thistab.get_selection()),
                 self._question_callback, ('n', 'N', 'y', 'Y'))
         else:
             # no need for a confirmation, just delete
@@ -733,7 +733,7 @@ class rename(Command):
         new_name = self.rest(1)
 
         tagged = {}
-        old_name = self.fm.thisfile.basename
+        old_name = self.fm.thisfile.relative_path
         for f in self.fm.tags.tags:
             if str(f).startswith(self.fm.thisfile.path):
                 tagged[f] = self.fm.tags.tags[f]
@@ -742,7 +742,7 @@ class rename(Command):
         if not new_name:
             return self.fm.notify('Syntax: rename <newname>', bad=True)
 
-        if new_name == self.fm.thisfile.basename:
+        if new_name == old_name:
             return
 
         if access(new_name, os.F_OK):
@@ -767,10 +767,10 @@ class rename_append(Command):
 
     def execute(self):
         cf = self.fm.thisfile
-        if cf.basename.find('.') != 0 and cf.basename.rfind('.') != -1 and not cf.is_directory:
-            self.fm.open_console('rename ' + cf.basename, position=(7 + cf.basename.rfind('.')))
+        if cf.relative_path.find('.') != 0 and cf.relative_path.rfind('.') != -1 and not cf.is_directory:
+            self.fm.open_console('rename ' + cf.relative_path, position=(7 + cf.relative_path.rfind('.')))
         else:
-            self.fm.open_console('rename ' + cf.basename)
+            self.fm.open_console('rename ' + cf.relative_path)
 
 class chmod(Command):
     """:chmod <octal number>
@@ -905,7 +905,7 @@ class relink(Command):
             return self.fm.notify('Syntax: relink <newpath>', bad=True)
 
         if not cf.is_link:
-            return self.fm.notify('%s is not a symlink!' % cf.basename, bad=True)
+            return self.fm.notify('%s is not a symlink!' % cf.relative_path, bad=True)
 
         if new_path == os.readlink(cf.path):
             return
@@ -1134,7 +1134,7 @@ class scout(Command):
                     thisdir.mark_item(f, value)
             else:
                 for f in thisdir.files:
-                    if regex.search(f.basename):
+                    if regex.search(f.relative_path):
                         thisdir.mark_item(f, value)
 
         if self.PERM_FILTER in flags:
@@ -1242,7 +1242,7 @@ class scout(Command):
         i = offset
         regex = self._build_regex()
         for fsobj in deq:
-            if regex.search(fsobj.basename):
+            if regex.search(fsobj.relative_path):
                 count += 1
                 if move and count == 1:
                     cwd.move(to=(cwd.pointer + i) % len(cwd.files))
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index fd883cb8..de0b5043 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -339,8 +339,8 @@ map =  chmod
 
 map cw console rename%space
 map a  rename_append
-map A  eval fm.open_console('rename ' + fm.thisfile.basename)
-map I  eval fm.open_console('rename ' + fm.thisfile.basename, position=7)
+map A  eval fm.open_console('rename ' + fm.thisfile.relative_path)
+map I  eval fm.open_console('rename ' + fm.thisfile.relative_path, position=7)
 
 map pp paste
 map po paste overwrite=True
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 9f554ad1..b851eece 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -20,12 +20,12 @@ from ranger.ext.human_readable import human_readable
 from ranger.container.settings import LocalSettings
 
 def sort_by_basename(path):
-    """returns path.basename (for sorting)"""
+    """returns path.relative_path (for sorting)"""
     return path.relative_path
 
 def sort_by_basename_icase(path):
-    """returns case-insensitive path.basename (for sorting)"""
-    return path.basename_lower
+    """returns case-insensitive path.relative_path (for sorting)"""
+    return path.relative_path_lower
 
 def sort_by_directory(path):
     """returns 0 if path is a directory, otherwise 1 (for sorting)"""
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 1bf08e20..a8c70e03 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -37,13 +37,14 @@ def safe_path(path):
 
 class FileSystemObject(FileManagerAware, SettingsAware):
     (basename,
-    basename_lower,
+    relative_path,
+    relative_path_lower,
     dirname,
     extension,
     infostring,
     path,
     permissions,
-    stat) = (None,) * 8
+    stat) = (None,) * 9
 
     (content_loaded,
     force_load,
@@ -100,7 +101,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
         else:
             self.basename = basename(path)
             self.relative_path = relpath(path, basename_is_rel_to)
-        self.basename_lower = self.relative_path.lower()
+        self.relative_path_lower = self.relative_path.lower()
         self.extension = splitext(self.basename)[1].lstrip(extsep) or None
         self.dirname = dirname(path)
         self.preload = preload
@@ -149,7 +150,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
     @lazy_property
     def basename_natural_lower(self):
         return [c if i % 3 == 1 else (int(c) if c else 0) for i, c in \
-            enumerate(_extract_number_re.split(self.basename_lower))]
+            enumerate(_extract_number_re.split(self.relative_path_lower))]
 
     @lazy_property
     def safe_basename(self):
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index 56fd3522..76e8f7cc 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -61,7 +61,7 @@ class TitleLinemode(LinemodeBase):
     required_metadata = ["title"]
 
     def filetitle(self, file, metadata):
-        name = metadata.title or file.basename
+        name = metadata.title
         if metadata.year:
             return "%s - %s" % (metadata.year, name)
         else:
revision' href='/akkartik/mu/blame/subx/036global_variables.cc?h=hlt&id=f39c01128dfc6e46828cbab992d4b9e0ba1cb1e5'>^
a6061b9f ^






9b16f190 ^
















a6061b9f ^
9b16f190 ^

a6061b9f ^









f75c7021 ^








5c368edc ^
f75c7021 ^
cac416f4 ^
f75c7021 ^

83c67014 ^
cac416f4 ^
f75c7021 ^
cac416f4 ^
f75c7021 ^



cac416f4 ^



f75c7021 ^












4a943d4e ^


83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^








a6517ed8 ^
4a943d4e ^


83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^








cac416f4 ^
4a943d4e ^

83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^






83c67014 ^



4a943d4e ^


a6061b9f ^
4a943d4e ^

83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^




83c67014 ^



4a943d4e ^


9b16f190 ^
4a943d4e ^


83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^







fb7cd3f1 ^
4a943d4e ^

83c67014 ^
4a943d4e ^
83c67014 ^
4a943d4e ^




f75c7021 ^
4a943d4e ^

83c67014 ^
4a943d4e ^





f75c7021 ^
f75c7021 ^









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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305