def parse_icon(d, path): check_allowed_properties(d, path, ("type", "name", "color")) check_required_properties(d, path, ("type", "name")) check_text(d['name'], path + ".name") if 'color' in d: check_color(d['color'], path + ".color")
def parse_document(d): check_allowed_properties(d, "#", ("version", "title", "elements")) check_required_properties(d, "#", ("version", "title", "elements")) check_version(d['version'], "#version") check_text(d['title'], "#title") parse_elements(d['elements'], "#elements")
def parse_text(d, path): check_allowed_properties(d, path, ("type", "text", "emphasis", "color")) check_required_properties(d, path, ("type", "text")) check_text(d['text'], path + ".text") if 'emphasis' in d: if d['emphasis'] not in ("bold", "italic"): raise ValidationError(path + ".emphasis", "not a valid value") if 'color' in d: check_color(d['color'], path + ".color")
def parse_pie(d, path): check_allowed_properties(d, path, ("type", "data", "name")) check_required_properties(d, path, ("type", "data", "name")) check_text(d['name'], path + ".name") for i in range(0, len(d['data'])): elem = d['data'][i] p = "%s.data[%s]" % (path, i) check_allowed_properties(elem, p, ("label", "value", "color")) check_required_properties(elem, p, ("label", "value", "color")) check_text(elem['label'], p + ".label") check_number(elem['value'], p + ".value") check_color(elem['color'], p + ".color")
def parse_heading(d, path): check_allowed_properties(d, path, ("type", "text")) check_required_properties(d, path, ("type", "text")) check_text(d['text'], path + ".text")