summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorAdam Porter <adam@alphapapa.net>2016-04-05 20:39:48 -0500
committerAdam Porter <adam@alphapapa.net>2016-04-05 20:39:48 -0500
commitfcfea319bffb2aea226914ab58098bb7514a0d28 (patch)
treef5346748a1df0b6ae4d8c54de5f8ab2df5b872d1 /ranger
parentb90640b0a99a98eb0db71417b0447eb077412785 (diff)
downloadranger-fcfea319bffb2aea226914ab58098bb7514a0d28.tar.gz
Add MtimeLinemode and SizeMtimeLinemode
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/fsobject.py3
-rw-r--r--ranger/core/linemode.py21
2 files changed, 23 insertions, 1 deletions
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index db6772ac..10f8259d 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -79,7 +79,8 @@ class FileSystemObject(FileManagerAware, SettingsAware):
     _linemode = DEFAULT_LINEMODE
     linemode_dict = dict(
         (linemode.name, linemode()) for linemode in
-        [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode]
+        [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode,
+         MtimeLinemode, SizeMtimeLinemode]
     )
 
     def __init__(self, path, preload=None, path_is_abs=False, basename_is_rel_to=None):
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index 76e8f7cc..b7aef23f 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -5,6 +5,8 @@
 
 import sys
 from abc import *
+from datetime import datetime
+from ranger.ext.human_readable import human_readable
 
 DEFAULT_LINEMODE = "filename"
 
@@ -102,3 +104,22 @@ class FileInfoLinemode(LinemodeBase):
             return fileinfo
         else:
             raise NotImplementedError
+
+class MtimeLinemode(LinemodeBase):
+    name = "mtime"
+
+    def filetitle(self, file, metadata):
+        return file.relative_path
+
+    def infostring(self, file, metadata):
+        return datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M")
+
+class SizeMtimeLinemode(LinemodeBase):
+    name = "sizemtime"
+
+    def filetitle(self, file, metadata):
+        return file.relative_path
+
+    def infostring(self, file, metadata):
+        return "%s %s" % (human_readable(file.size),
+                          datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M"))
vision' href='/akspecs/ranger/blame/doc/pydoc/ranger.fsobject.fsobject.html?h=v1.9.0b5&id=0654d6d093f8e78033b9dcafcb52bbdcd92aed0c'>^
f07bb12f ^

















34a60763 ^
f07bb12f ^




a614f048 ^

f07bb12f ^
























62cd83ba ^
c776804d ^

62cd83ba ^


f07bb12f ^


























34a60763 ^



f07bb12f ^
























































34a60763 ^
f07bb12f ^





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