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"))