def go(): library = library_from_env(e) image_source = image_source_from_env(e) ndp = library.load_ndp(e.thing_name) mf = MakeFiguresNDP(ndp=ndp, image_source=image_source, yourname=e.thing_name) data = mf.get_figure(which, data_format) mime = get_mime_for_format(data_format) return response_data(request=e.request, data=data, content_type=mime)
def __call__(self, data): ndp = get_ndp(data) library = data['library'] paths = library.get_images_paths() image_source = ImagesFromPaths(paths) mf = MakeFiguresNDP(ndp=ndp, image_source=image_source, yourname=None) formats = mf.available_formats(self.name) res = mf.get_figure(self.name, formats) results = [(_, self.name, res[_]) for _ in formats] return results
def figint01(): ndp = parse_ndp(""" mcdp { } """) mf = MakeFiguresNDP(ndp=ndp, image_source=None, yourname=None) for name in mf.available(): formats = mf.available_formats(name) res = mf.get_figure(name, formats) print('%s -> %s %s ' % (name, formats, map(len, [res[f] for f in formats])))
def callback(tag0): assert tag0.parent is not None context = Context() load = lambda x: library.load_ndp(x, context=context) parse = lambda x: library.parse_ndp(x, realpath=realpath, context=context) ndp = load_or_parse_from_tag(tag0, load, parse) mf = MakeFiguresNDP(ndp=ndp, image_source=image_source, yourname=None) # XXX formats = ['svg'] if generate_pdf: formats.append('pdf') data = mf.get_figure(which,formats) tag = make_tag(tag0, which, data, ndp=ndp, template=None) return tag
def allformats_report(id_ndp, ndp, libname, which): from mcdp_web.images.images import get_mime_for_format from mcdp_library_tests.tests import get_test_library r = Report(id_ndp + '-' + which) library = get_test_library(libname) image_source = ImagesFromPaths(library.get_images_paths()) mf = MakeFiguresNDP(ndp=ndp, image_source=image_source, yourname=id_ndp) formats = mf.available_formats(which) try: res = mf.get_figure(which, formats) except DPSemanticError as e: if 'Cannot abstract' in str(e): r.text('warning', 'Not connected. \n\n %s' % e) return r print('%s -> %s %s ' % (which, formats, map(len, [res[f] for f in formats]))) fig = r.figure() for f in formats: data = res[f] mime = get_mime_for_format(f) dn = DataNode(f, data=data, mime=mime) fig.add_child(dn) return r