import types
import re
-key_pattern = re.compile("\A[A-Za-z0-9_-]+\Z")
+key_pattern_str = "\A[A-Za-z0-9_-]+\Z"
+key_pattern = re.compile(key_pattern_str)
-class InvalidStatusFile(Exception):
+class InvalidStatusFile(StandardError):
pass
-class Status:
+class Status(object):
"""
- (One subtree of) Moe status file.
+ (One subtree of) a status file.
+
+ Each Status is a dictionary with string keys matching the specs. and
+ values either strings or nested Status subtrees.
+
+ The class defines `__getitem__`, `__setitem__`, `__eq__` and `keys`.
"""
def __init__(self):
this = stk.pop()
else:
raise InvalidStatusFile("Parse error: malformed line")
+ if stk:
+ raise InvalidStatusFile("Parse error: not all subtrees closed")