def go(): l = self.get_library(request) id_ndp = self.get_model_name(request) context = l._generate_context_with_hooks() ndp = l.load_ndp(id_ndp, context) mf = MakeFiguresNDP(ndp=ndp, library=l, yourname=id_ndp) data_format = str(request.matchdict['format']) data = mf.get_figure('ndp_graph_templatized', data_format) mime = get_mime_for_format(data_format) return response_data(request=request, data=data, content_type=mime)
def __call__(self, data): ndp = get_ndp(data) library = data['library'] mf = MakeFiguresNDP(ndp=ndp, library=library, 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 callback(tag0): source_code = tag0.string.encode('utf-8') context = Context() ndp = library.parse_ndp(source_code, realpath=realpath, context=context) mf = MakeFiguresNDP(ndp=ndp, library=library, 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 figint01(): ndp = parse_ndp(""" mcdp { } """) mf = MakeFiguresNDP(ndp=ndp, library=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 allformats_report(id_ndp, ndp, libname, which): from mcdp_web.images.images import get_mime_for_format r = Report(id_ndp + '-' + which) from mcdp_library_tests.tests import get_test_library library = get_test_library(libname) mf = MakeFiguresNDP(ndp=ndp, library=library, 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
def get_png_data_model(library, name, ndp, data_format): mf = MakeFiguresNDP(ndp=ndp, library=library, yourname=name) f = 'fancy_editor' res = mf.get_figure(f, data_format) return res