示例#1
0
def generate_examples(outformat, dpi):
    for c in configs:
        config_fname = c.keys()[0]
        params = c.values()[0]

        for p in params:
            data_fname = os.path.join(DATA_PATH, p['data'] + '.json')
            colorscheme = p['colors']

            out_fname = [config_fname]
            if colorscheme:
                out_fname.append(colorscheme)
            out_fname.append(os.path.basename(os.path.splitext(data_fname)[0]))

            out_fname = os.path.join(OUT_PATH, outformat,
                                     '-'.join(out_fname) + '.' + outformat)

            print "Generating '%s'..." % out_fname,
            scale = get_scale_factor(dpi, 1.0);
            generate_output(data_fname, config_fname, out_fname, outformat,
                            colorscheme=colorscheme, scale=scale)
            print 'OK'
示例#2
0
文件: cmdline.py 项目: johnnovak/twyg
        return 2

    if options.dpi <= 0:
        parser.error('DPI value must be greater than 0')
        return 2

    if options.scale <= 0:
        parser.error('scale value must be greater than 0')
        return 2

    # Validate margin values
    margins = options.margin.split(',')
    try:
        validate_margins(margins)
    except ValueError, e:
        parser.error(e)
        return 2

    try:
        scale = get_scale_factor(options.dpi, options.scale)

        generate_output(datafile, options.config, outfile, options.outformat,
                        colorscheme=options.colorscheme, scale=scale,
                        margins=margins)

    except Exception, e:
        exit_error(traceback.format_exc() if options.verbose else str(e))

    return 0

示例#3
0
文件: cmdline.py 项目: johnnovak/twyg
        parser.error('DPI value must be greater than 0')
        return 2

    if options.scale <= 0:
        parser.error('scale value must be greater than 0')
        return 2

    # Validate margin values
    margins = options.margin.split(',')
    try:
        validate_margins(margins)
    except ValueError, e:
        parser.error(e)
        return 2

    try:
        scale = get_scale_factor(options.dpi, options.scale)

        generate_output(datafile,
                        options.config,
                        outfile,
                        options.outformat,
                        colorscheme=options.colorscheme,
                        scale=scale,
                        margins=margins)

    except Exception, e:
        exit_error(traceback.format_exc() if options.verbose else str(e))

    return 0