X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=lbs.py;h=3f647c46a7eea2e7d98f0f54c75a80a93daf7cac;hb=0ccc8bda8094a3a3ad9cec58916c0a740dd33628;hp=5077a7a32bdad80ac38aa11d31a8684f4252538b;hpb=2edfbb7e1a547f1c75b8091955805c6c19e8c31a;p=cumulus.git diff --git a/lbs.py b/lbs.py index 5077a7a..3f647c4 100644 --- a/lbs.py +++ b/lbs.py @@ -12,6 +12,9 @@ from __future__ import division import os, re, sha, tarfile, tempfile, thread from pysqlite2 import dbapi2 as sqlite3 +# The largest supported snapshot format that can be understood. +FORMAT_VERSION = (0, 2) # LBS Snapshot v0.2 + # Maximum number of nested indirect references allowed in a snapshot. MAX_RECURSION_DEPTH = 3 @@ -261,6 +264,15 @@ def parse_full(lines): except StopIteration: return {} +def parse_metadata_version(s): + """Convert a string with the snapshot version format to a tuple.""" + + m = re.match(r"^LBS Snapshot v(\d+(\.\d+)*)$", s) + if m is None: + return () + else: + return tuple([int(d) for d in m.group(1).split(".")]) + def read_metadata(object_store, root): """Iterate through all lines in the metadata log, following references."""