import datetime # 3rd party from monk import modeling, nullable, optional, IsA, Equals, Exists fact_schema = OrderedDict([ (Equals('category') | ~Exists(), str), ('activity', str), ('since', datetime.datetime.now), ('until', datetime.datetime), (Equals('tags') | ~Exists(), [ IsA(str) | Equals(None) | ~Exists(), ]), (Equals('hamster_fact_id') | ~Exists(), int), # legacy ('description', nullable(str)), ]) class Model(modeling.TypedDictReprMixin, modeling.DotExpandedDictMixin, modeling.StructuredDictMixin, dict): def __init__(self, *args, **kwargs): super(Model, self).__init__(*args, **kwargs) self._insert_defaults() self._make_dot_expanded() class Fact(Model):
from . import utils # for Concern.sorted_plans if compat.PY3: unicode = str __all__ = ['Concern', 'contact_schema', 'asset_schema', 'project_schema'] #--- Pure Schemata log_schema = { 'time': datetime.datetime, opt_key('note'): nullable(unicode), 'data': dict, } referenced_item_schema = [unicode] # Rule(list, inner_spec=unicode) referenced_items_schema = translate({ opt_key('assets'): referenced_item_schema, opt_key('contacts'): referenced_item_schema, opt_key('projects'): referenced_item_schema, opt_key('reference'): referenced_item_schema, }) & Length(min=1) STATUS_TODO = u'todo' STATUS_WAITING = u'waiting'