summaryrefslogtreecommitdiff
path: root/contrib/ledger-du
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-23 14:04:50 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-23 14:04:50 -0400
commit08559bff349b8266331389c9a0c579798ce94b4c (patch)
tree829d8c4f0c12855814d1d4891889fbfc655de8ed /contrib/ledger-du
parenta61901a0923a1b4413fcc44a8ff259d309c064b0 (diff)
downloadfork-ledger-08559bff349b8266331389c9a0c579798ce94b4c.tar.gz
fork-ledger-08559bff349b8266331389c9a0c579798ce94b4c.tar.bz2
fork-ledger-08559bff349b8266331389c9a0c579798ce94b4c.zip
Moved scripts from contrib/scripts/ into contrib/
Diffstat (limited to 'contrib/ledger-du')
-rwxr-xr-xcontrib/ledger-du49
1 files changed, 49 insertions, 0 deletions
diff --git a/contrib/ledger-du b/contrib/ledger-du
new file mode 100755
index 00000000..f5d7dd7d
--- /dev/null
+++ b/contrib/ledger-du
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+import string
+import sys
+import os
+import time
+
+from stat import *
+from os.path import *
+
+def report_file(path):
+ dir_elems = string.split(dirname(path), os.sep)
+ if dir_elems[0] == "." or dir_elems[0] == "":
+ dir_elems = dir_elems[1 :]
+ account = string.join(dir_elems, ":")
+
+ info = os.stat(path)
+ print time.strftime("%Y/%m/%d", time.localtime(info[ST_MTIME])),
+
+ print basename(path)
+ print " ", account, " ", info[ST_SIZE], "b"
+ print " Equity:Files"
+ print
+
+def find_files(path):
+ entries = os.listdir(path)
+ for entry in entries:
+ entry = join(path, entry)
+ if not islink(entry):
+ if isdir(entry) and entry != "/proc":
+ find_files(entry)
+ else:
+ report_file(entry)
+
+args = sys.argv[1:]
+if len(args):
+ paths = args
+else:
+ paths = ["."]
+
+print """
+C 1.00 Kb = 1024 b
+C 1.00 Mb = 1024 Kb
+C 1.00 Gb = 1024 Mb
+C 1.00 Tb = 1024 Gb
+"""
+
+for path in paths:
+ find_files(path)