summaryrefslogtreecommitdiffstats
path: root/module/Utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/Utils.py')
-rw-r--r--module/Utils.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/module/Utils.py b/module/Utils.py
index b85f48210..de07a9450 100644
--- a/module/Utils.py
+++ b/module/Utils.py
@@ -42,5 +42,21 @@ def freeSpace(folder):
s = statvfs(folder)
return s.f_bsize * s.f_bavail / 1024 / 1024 #megabyte
+def uniqify(seq, idfun=None):
+ # order preserving
+ if idfun is None:
+ def idfun(x): return x
+ seen = {}
+ result = []
+ for item in seq:
+ marker = idfun(item)
+ # in old Python versions:
+ # if seen.has_key(marker)
+ # but in new ones:
+ if marker in seen: continue
+ seen[marker] = 1
+ result.append(item)
+ return result
+
if __name__ == "__main__":
- print freeSpace(".") \ No newline at end of file
+ print freeSpace(".")