Beispiel #1
0
def main():
    data = {
        "view": "Terminal",
        "name": "Terminal marked example",
        "value": u"Zażółć gęślą jaźń",
        "mark": "yes"
    }
    conf = {
        "terminal": {
            "padding": 8
        }
    }
    path = sys.argv[1] if len(sys.argv) == 2 else "output"
    images = sdgen.to_png(data, path=path, conf=conf, overwrite=True)
    return images
Beispiel #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
sys.path.append(os.path.join('..', '..', 'src'))

import sdgen

data = {
    "view": "Group",
    "name": "QuantityAbove example",
    "children": [
        {"view": "Terminal", "value": "A"},
        {
            'children': [
                {"view": "Terminal", "value": "B"}
            ],
            "name": "Quantity Above B",
            "view": "QuantityAbove",
            "value": "0..n"
        },
        {"view": "Terminal", "value": "C"}
    ]
}

if __name__ == '__main__':
    path = sys.argv[1] if len(sys.argv) == 2 else "output"
    result = sdgen.to_png(data, path, overwrite=True)
Beispiel #3
0
import sys

sys.path.append(os.path.join('..', '..', 'src'))

from sdgen import to_png

EXAMPLES_DIR = '.'
OUTPUT_DIR = sys.argv[1] if len(sys.argv) == 2 else 'output'
EXAMPLES_EXT = '.json'

if __name__ == '__main__':
    print "Generating examples from JSON files..."

    examples = sorted([os.path.join(EXAMPLES_DIR, f) for f in os.listdir(EXAMPLES_DIR) if f.endswith(EXAMPLES_EXT)])
    for example in examples:
        print "processing " + example
        # load data
        example_file = open(example, 'r')
        m = json.load(example_file)

        name = m['name']

        conf = {
             'png': {
                 'ppi': 300
             }
        }
        r = to_png(m, OUTPUT_DIR, conf=conf, overwrite=True)

    print "done"
Beispiel #4
0
"""

examples = ["ex01", "ex05", "ex07", "ex06", "ex02", "ex10", "ex04", "ex03", "ex09"]

if __name__ == "__main__":
    print "Generating examples...",

    txt = open("source/_generated/examples.txt", "w")

    txt.write(TEMPLATE_HEADER)

    for example in examples:
        # load data
        m = imp.load_source("m", "../examples/%s.py" % example)

        name = m.data["name"]
        path = "../../../examples/%s.py" % example

        # put header and source code of an example
        txt.write(TEMPLATE_NAME % (name, "=" * len(name), path))

        # add images
        r = to_png(m.data, "source/_generated/")

        for i in r:
            filename = i[0].translate(string.maketrans(" ", "_")) + ".png"

            txt.write(TEMPLATE_IMAGE % filename)

    print "done"
Beispiel #5
0
    txt.write(TEMPLATE_HEADER)

    examples = sorted([os.path.join(EXAMPLES_DIR, f) for f in os.listdir(EXAMPLES_DIR) if f.endswith(EXAMPLES_EXT)])
    for example in examples:
        # load data
        example_file = open(example, 'r')
        m = json.load(example_file)

        name = m['name']
        path_from_generated = os.path.join('..', '..', example)

        # put json contentof an example
        txt.write(TEMPLATE_NAME % (name, '-' * len(name), path_from_generated))

        conf = {
            'png': {
                'ppi': 150
            }
        }

        # add images
        r = to_png(m, EXAMPLES_GENERATED_DIR, conf=conf, overwrite=True)

        for i in r:
            filename = i[0].replace(' ', '_').lower() + ".png"
            img_path = os.path.join('..', GENERATED_DIR, filename)
            txt.write(TEMPLATE_IMAGE % img_path)

    print "done"