]> arthur.barton.de Git - bup.git/blob - t/data-size
d7da54560aee47aac9f03f34c9edaedfab447e10
[bup.git] / t / data-size
1 #!/bin/sh
2 """": # -*-python-*-
3 bup_python="$(dirname "$0")/../cmd/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
5 """
6 # end of bup preamble
7
8 from os.path import getsize, isdir
9 from sys import argv, stderr
10 import os
11
12 def listdir_failure(ex):
13     raise ex
14
15 def usage():
16     print >> stderr, "Usage: data-size PATH ..."
17
18 total = 0
19 for path in argv[1:]:
20     if isdir(path):
21         for root, dirs, files in os.walk(path, onerror=listdir_failure):
22             total += sum(getsize(os.path.join(root, name)) for name in files)
23     else:
24         total += getsize(path)
25
26 print total