summaryrefslogtreecommitdiffstats
path: root/src/fringlib/fringdata.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fringlib/fringdata.py')
-rw-r--r--src/fringlib/fringdata.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/fringlib/fringdata.py b/src/fringlib/fringdata.py
index a9bea69..1da49c0 100644
--- a/src/fringlib/fringdata.py
+++ b/src/fringlib/fringdata.py
@@ -13,6 +13,10 @@ class SumList:
self.children.append(sumlist)
self.size += sumlist.size
+ def has_children(self):
+ if len(self.children) > 0: return True
+ return False
+
def printout(self, tab=0 ):
print " "*tab,"%s (%i)"%(sumlist.name,sumlist.size)
if not sumlist.children: return
@@ -54,5 +58,43 @@ class SumList:
return 3
+#==================================================================================
+class SumListCollection:
+ """ A repository for folder data.
+
+ Is filled by the walker, and retrieved by the UI class.
+ An int is used to track changes in a path.
+
+ Since sumlists are objects, python will store references to them instead
+ of copying the data (as it would with tuples).
+ """
+
+ def __init__(self):
+ self.clear()
+
+ def set_sumlist(self, uri, sumlist):
+ if not isinstance(sumlist,SumList): raise ValueError
+ if not isinstance(uri,unicode): raise ValueError
+ if not sumlist.has_children(): return # skip files
+ self.collection[uri] = sumlist
+ if uri in self.versionControl:
+ self.versionControl[uri] += 1
+ else:
+ self.versionControl[uri] = 0
+
+ def get_sumlist(self, uri):
+ if uri in self.collection:
+ return self.collection[uri]
+
+ def has_changed(self, uri, version):
+ if uri in self.versionControl:
+ if version != self.versionControl[uri]:
+ return True
+ return False
+
+ def clear(self):
+ self.collection = {}
+ self.versionControl = {}
+ gc.collect()