Example #1
0
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")
Example #2
0
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")
Example #3
0
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")
Example #4
0
def parse_grid(d, path):
    check_allowed_properties(d, path, ("type", "rows"))
    check_required_properties(d, path, ("type", "rows"))

    if not isinstance(d['rows'], list):
        raise ValidationError(path + ".rows", "must be an array")

    if not d['rows']:
        raise ValidationError(path + ".rows", "must not be empty")

    for i in range(0, len(d['rows'])):
        r = d['rows'][i]
        parse_elements(r, "%s.rows[%s]" % (path, i))
Example #5
0
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")
Example #6
0
def parse_paragraph(d, path):
    check_allowed_properties(d, path, ("type", "elements"))
    check_required_properties(d, path, ("type", "elements"))
    parse_elements(d['elements'], path + ".elements")
Example #7
0
def parse_unordered_list(d, path):
    check_allowed_properties(d, path, ("type", "elements"))
    check_required_properties(d, path, ("type", "elements"))
    parse_elements(d['elements'], path + ".elements")
Example #8
0
def parse_hline(d, path):
    check_allowed_properties(d, path, ("type", ))
    check_required_properties(d, path, ("type", ))
Example #9
0
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")