]> arthur.barton.de Git - bup.git/blob - t/data-size
test-restore-map-owner: accommodate python 3 and test there
[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 __future__ import absolute_import, print_function
9
10 from os.path import getsize, isdir
11 from sys import argv, stderr
12 import os
13
14 def listdir_failure(ex):
15     raise ex
16
17 def usage():
18     print('Usage: data-size PATH ...', file=sys.stderr)
19
20 total = 0
21 for path in argv[1:]:
22     if isdir(path):
23         for root, dirs, files in os.walk(path, onerror=listdir_failure):
24             total += sum(getsize(os.path.join(root, name)) for name in files)
25     else:
26         total += getsize(path)
27
28 print(total)