diff options
| author | Fraxinas <andreas.frisch@multimedia-labs.de> | 2009-07-29 10:12:31 +0200 |
|---|---|---|
| committer | Fraxinas <andreas.frisch@multimedia-labs.de> | 2009-07-29 10:12:31 +0200 |
| commit | eded0db3bc821a1633da2fd33cf0019407dd1089 (patch) | |
| tree | 33db8faf5b7f50e4f333fde9a4a7b45db0d718c0 /lib/python/Tools | |
| parent | 8bea76d0df509b8d3f570d67a1855efa49c3eaaf (diff) | |
| download | enigma2-eded0db3bc821a1633da2fd33cf0019407dd1089.tar.gz enigma2-eded0db3bc821a1633da2fd33cf0019407dd1089.zip | |
add getSize convenience function to obtain file or directory size (not tested with directories containing lots of files)
Diffstat (limited to 'lib/python/Tools')
| -rwxr-xr-x | lib/python/Tools/Directories.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index f9394978..aaa2a9da 100755 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -262,3 +262,14 @@ def copytree(src, dst, symlinks=False): utime(dst, (st.st_atime, st.st_mtime)) except: print "copy stats for", src, "failed!" + +def getSize(path, pattern=".*"): + path_size = 0 + if os_path.isdir(path): + files = crawlDirectory(path, pattern) + for file in files: + filepath = os_path.join(file[0], file[1]) + path_size += os_path.getsize(filepath) + elif os_path.isfile(path): + path_size = os_path.getsize(path) + return path_size |
