Commits

Ronny Pfannschmidt committed 4bee787

move some code around, enhance docs

  • Participants
  • Parent commits 538741a

Comments (0)

Files changed (4)

File bmst/main.py

 
 
 from bmst.backup_app import make_backup
-from bmst.managed import BMST, check_bmst, dumb_sync
+from bmst.managed import BMST, check_bmst
 from bmst.store import FileStore, Httplib2Store
 from bmst.utils import archive, extract, sync, get_bmst
 

File bmst/managed.py

 
 
 def find_missing_blobs(expected, store):
+    """
+    utility to check if any blobs for a meta item are missing
+    """
     keys = set(store.keys())
     missing = {}
     for name, value in expected.items():
 
 
 def sha1(data):
+    """
+    shortcut to get a hexdigest sha1 of some data
+    """
     return hashlib.sha1(data).hexdigest()
 
 
-def dumb_sync(source, target):
+def check_store(bmst, kind):
     """
-    sync items from source to target
+    check hash consistency of the store `kind` in `bmst`
     """
-    to_sync = set(source) - set(target)
-    for item in to_sync:
-        target[item] = source[item]
-
-
-def check_store(bmst, kind):
     print 'checking', kind
     store = getattr(bmst, kind)
     errors = []
 
 
 def check_references(bmst):
+    """
+    check if all blobs required for the mea items exist
+    """
     print 'checking references'
     all_missing = {}
     for item in bmst.meta:
 
 
 def find_orphans(bmst):
+    """
+    search for unreferenced blobs
+    """
     print 'searching orphan blobs'
     known = set(bmst.blobs)
     for item in bmst.meta:
 
 
 def encode_data(raw_data, key):
+    """
+    utility function to check or generate the key of a data item and compress it in one step
+    """
     computed_key = sha1(raw_data)
     if key is not None and computed_key != key:
         raise ValueError('%r != %r)' % (key, computed_key))

File bmst/store.py

 
     in general a store is a mutable mapping that will not allow delete
 """
-
-
 import py
 import collections
 import json
 
 
+def dumb_sync(source, target):
+    """
+    sync items from source store to target store
+    """
+    to_sync = set(source) - set(target)
+    for item in to_sync:
+        target[item] = source[item]
+
+
 class BaseStore(collections.MutableMapping):
     """
     convience base class implementing osme defualt methods for stores

File bmst/utils.py

 from __future__ import print_function
 import json
 import py
-from bmst.managed import dumb_sync, BMST
-from bmst.store import FileStore, Httplib2Store
+from bmst.managed import BMST
+from bmst.store import FileStore, Httplib2Store, dumb_sync
 
 
 def get_bmst(path):