From d0e513d4371789d59bcb902497ca7c537a94c1f0 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Fri, 15 Nov 2013 18:08:50 +0100 Subject: pybootchartgui: Import pybootchartgui 0.14.5 This update the pybootchartgui code to the latest release from its new location at "https://github.com/mmeeks/bootchart". This only imports the relevant parts, and not all of bootchart2. (From OE-Core rev: 6f1568e54a7808b2ab568618fc5bb244249579f1) Signed-off-by: Peter Kjellerstedt Signed-off-by: Richard Purdie --- scripts/pybootchartgui/pybootchartgui/batch.py | 53 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'scripts/pybootchartgui/pybootchartgui/batch.py') diff --git a/scripts/pybootchartgui/pybootchartgui/batch.py b/scripts/pybootchartgui/pybootchartgui/batch.py index 3c1dbf8416..05c714e95e 100644 --- a/scripts/pybootchartgui/pybootchartgui/batch.py +++ b/scripts/pybootchartgui/pybootchartgui/batch.py @@ -1,23 +1,46 @@ -import cairo +# This file is part of pybootchartgui. + +# pybootchartgui is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# pybootchartgui is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -import draw +# You should have received a copy of the GNU General Public License +# along with pybootchartgui. If not, see . -def render(res, format, filename): +import cairo +from . import draw +from .draw import RenderOptions + +def render(writer, trace, app_options, filename): handlers = { - "png": (lambda w,h: cairo.ImageSurface(cairo.FORMAT_ARGB32,w,h), lambda sfc: sfc.write_to_png(filename)), - "pdf": (lambda w,h: cairo.PDFSurface(filename, w, h), lambda sfc: 0), - "svg": (lambda w,h: cairo.SVGSurface(filename, w, h), lambda sfc: 0) + "png": (lambda w, h: cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h), \ + lambda sfc: sfc.write_to_png(filename)), + "pdf": (lambda w, h: cairo.PDFSurface(filename, w, h), lambda sfc: 0), + "svg": (lambda w, h: cairo.SVGSurface(filename, w, h), lambda sfc: 0) } - if not(handlers.has_key(format)): - print "Unknown format '%s'." % format + if app_options.format is None: + fmt = filename.rsplit('.', 1)[1] + else: + fmt = app_options.format + + if not (fmt in handlers): + writer.error ("Unknown format '%s'." % fmt) return 10 - make_surface, write_surface = handlers[format] - w,h = draw.extents(res) - w = max(w, draw.MIN_IMG_W) - surface = make_surface(w,h) - ctx = cairo.Context(surface) - draw.render(ctx, res) - write_surface(surface) + make_surface, write_surface = handlers[fmt] + options = RenderOptions (app_options) + (w, h) = draw.extents (options, 1.0, trace) + w = max (w, draw.MIN_IMG_W) + surface = make_surface (w, h) + ctx = cairo.Context (surface) + draw.render (ctx, options, 1.0, trace) + write_surface (surface) + writer.status ("bootchart written to '%s'" % filename) -- cgit v1.2.3-54-g00ecf