Beispiel #1
0
def generateHtml(content):
    template_name = "ns.html"
    template = loader.load(template_name)
    # stream = template.generate(unscheduled = UNSCHEDULED, scheduled = SCHEDULED)
    stream = template.generate(message=content)
    rendered = stream.render('html', doctype='html5')
    return rendered
Beispiel #2
0
    def index(self, default=None):
        """Return the index page."""

        template = self._loader.load('index.html')
        return template.generate(partner_id='direct',
                                 default=default,
                                 agreements=agreements.handlers).render('xhtml')
Beispiel #3
0
    def index(self):

        query = self.session.query(scicom.mta.material.Material)
        materials = query.select()
        template = self.__loader.load('material-index.html')
        stream = template.generate(materials=materials)
        return stream.render('xhtml')
Beispiel #4
0
    def index(self, default=None):
        """Return the index page."""

        template = self._loader.load('index.html')
        return template.generate(
            partner_id='direct',
            default=default,
            agreements=agreements.handlers).render('xhtml')
Beispiel #5
0
    def view(self, id):

        # get the Material
        query = self.session.query(scicom.mta.material.Material)
        material = query.select_by(material_id=id)

        # pass the Material off to a template
        template = self.__loader.load('material.html')
        stream = template.generate(material=material[0])

        return stream.render('xhtml')
Beispiel #6
0
 def __render(self, file):
     engine = harkfm.Engine()
     template = self.__class__.loader.load(file)
     search_path = 'file:///' + self.__class__.loader.search_path[0].replace('\\', '/') + '/'
     html = template.generate(
         current=engine.current,
         lastfm=engine.lfm_props(),
         config=harkfm.Storage.config
     ).render('html', doctype='html')
     self.QWebEngineView.setHtml(html, QUrl(search_path))
     self.__class__._last_page = file
Beispiel #7
0
def generate(dir, xslt, blog_entries, reading_entries, config):
    # index
    template = template_loader.load('index.html')
    rendered = template.generate(blog_entries=blog_entries, 
            reading_entries=reading_entries, 
            config=config).render('xhtml')
    transformed = str(xslt(lxml.etree.fromstring(rendered)))
    constance.output(os.path.join(dir, 'index.html'), transformed)

    # firehose
    rendered = template_loader.load('firehose.atom').generate(
            items=chain(blog_entries, reading_entries),
            config=config).render('xml')
    constance.output(os.path.join(dir, 'firehose.atom'), rendered)
Beispiel #8
0
    def iframe(self, partner_id=None, stylesheet=None, default=None):

        # partner_id is required
        if partner_id is None:
            raise MissingParameterException()

        # render the template and return the value
        template = self._loader.load('iframe.html')
        stream = template.generate(partner_id=partner_id,
                                   default=default,
                                   stylesheet=stylesheet,
                                   agreements=agreements.handlers)

        return stream.render('xhtml')
Beispiel #9
0
    def iframe(self, partner_id=None, stylesheet=None, default=None):

        # partner_id is required
        if partner_id is None:
            raise MissingParameterException()

        # render the template and return the value
        template = self._loader.load('iframe.html')
        stream = template.generate(partner_id=partner_id,
                                   default=default,
                                   stylesheet=stylesheet,
                                   agreements=agreements.handlers
                                   )

        return stream.render('xhtml')
Beispiel #10
0
def rendered_markup_eq_(template_text, **context):
    import genshi, genshi.template

    chunked_raw = chunk_assertion_blocks(template_text)
    if not chunked_raw:
        raise AssertionError("No test chunks found in template text.")

    template = genshi.template.MarkupTemplate(template_text)
    stream = template.generate(**context)
    output = stream.render('xhtml')
    chunked_output = chunk_assertion_blocks(output)

    for idx, label, lhs, rhs in chunked_output:
        assert lhs == rhs, "test %s: %r != %r" % (label, lhs, rhs)

    eq_(len(chunked_raw), len(chunked_output))
Beispiel #11
0
def rendered_markup_eq_(template_text, **context):
    import genshi, genshi.template

    chunked_raw = chunk_assertion_blocks(template_text)
    if not chunked_raw:
        raise AssertionError("No test chunks found in template text.")

    template = genshi.template.MarkupTemplate(template_text)
    stream = template.generate(**context)
    output = stream.render('xhtml')
    chunked_output = chunk_assertion_blocks(output)

    for idx, label, lhs, rhs in chunked_output:
        assert lhs == rhs, "test %s: %r != %r" % (label, lhs, rhs)

    eq_(len(chunked_raw), len(chunked_output))
Beispiel #12
0
def write(file_number, variables):
    for number in range(1, 5):
        variables.setdefault('summary%d' % number, '.' * 60)
        variables.setdefault('id%d' % number, '        ')
        variables.setdefault('description%d' % number, '')

    svg_filename = 'cards%s.svg' % file_number
    pdf_filename = 'cards%s.pdf' % file_number

    print 'Creating', svg_filename
    output = codecs.open(svg_filename, 'w', 'utf-8')
    svg = unicode(template.generate(**variables))
    output.write(svg)
    output.close()

    print 'Creating', pdf_filename
    subprocess.check_call(['inkscape', '--export-pdf', pdf_filename, svg_filename])
    pdf_filenames.append(pdf_filename)
Beispiel #13
0
 def generate(self, template, context):
     return template.generate(context)
Beispiel #14
0
    def agreement(self, code, version):

        template = self.__loader.load("deed.html")
        stream = template.generate(code=code, version=version)

        return stream.render("xhtml")
Beispiel #15
0
 def generate(self, template, context):
     from flatland.out.genshi import flatland_filter
     return flatland_filter(template.generate(context), context)
Beispiel #16
0
 def generate(self, template, context):
     return template.generate(context)
Beispiel #17
0
	def index(self):
		cherrypy.response.headers['Content-Type'] = 'application/xhtml+xml'
		template = self.get_template()
		not_watched = lambda m: m.class_ != 'watched'
		movies = Index(filter=not_watched)
		return template.generate(movies=movies, title="Movies to Watch").render('xml')
Beispiel #18
0
 def embed_gen(self, debug):
     template = self.__loader.load("embed-wizard.html")
     stream = template.generate(embedded=True, debug=debug)
     lines = stream.render("xhtml").split('\n')
     return '\n'.join(map(lambda l: "document.write('%s');" % l.replace("'","\\'"), lines))
Beispiel #19
0
 def chooser_gen(self, template_file="chooser.html", debug=False, embedded=False):
     template = self.__loader.load(template_file)
     stream = template.generate(debug=debug, embedded=embedded)
     return stream.render("xhtml")        
Beispiel #20
0
 def generate(self, template, context):
     from flatland.out.genshi import flatland_filter
     return flatland_filter(template.generate(context), context)
Beispiel #21
0
	def render (self, template, beans) :
		template = self.context.template_loader.load (template)
		beans['float'] = render_float
		return template.generate (** beans) .render ('html', doctype = 'html')
Beispiel #22
0
    def stats(self):
        """Return the stats page."""

        template = self._loader.load('stats.html')
        return template.generate(total = self._stats.total(),
                                 counts = self._stats.counts()).render('xhtml')
Beispiel #23
0
    def stats(self):
        """Return the stats page."""

        template = self._loader.load('stats.html')
        return template.generate(total=self._stats.total(),
                                 counts=self._stats.counts()).render('xhtml')
Beispiel #24
0
        dsn = 'rocky2lemma'
        
        plot_db = db.PlotDatabase(model_type, model_region, buffer,
                                  model_year, summary_level, 
                                  image_source, image_version, dsn)
        
        metadata = plot_db.get_metadata_field_dictionary(table_name)
        
        ordinal_dict = {}
        for key in metadata.keys():
            ordinal_dict[metadata[key]['ORDINAL']] = key
        
        for ordinal in sorted(ordinal_dict.keys()):
            key = ordinal_dict[ordinal]
            yield metadata[key]
        
if __name__ == '__main__':
    #name of database table for which to generate metadata
    table_name = sys.argv[1]
    #name and path of output xml file containing metadata
    out_file = sys.argv[2]
    
    loader = template.TemplateLoader(['C:/code/interpreted_redesign/metadata/templates/'])
    template = loader.load('sppsz_all_template.xml')
    meta = GenerateMetadata()
    #collection = meta.create_metadata_file(table_name)
    #stream = template.generate(collection)
    stream = template.generate(collection=meta.create_metadata_file(table_name))
    out_fh = open(out_file, 'w')
    out_fh.write(stream.render('xml'))
    
Beispiel #25
0
 def mesh_test(self):
     template = self.__loader.load("mesh-test.html")
     stream = template.generate()
     return stream.render("xhtml")        
Beispiel #26
0
    def legalcode(self, code, version, kwargs):

        template = self.__loader.load("legal.html")
        stream = template.generate(agreementType=code, version=version, agreementText=self.legaltext(code, version), **kwargs)
        return stream.render("xhtml")
Beispiel #27
0
    def deed(self, code, version, kwargs):
        template = self.__loader.load("deed.html")
        basecode = self.basecode(code)

        # same for all deeds
        permissions = [
            {'long': 'Use the materials for research that you supervise',
             'uri': 'sc:YourResearch'},
            {'long': 'Allow others under your supervision to use the materials',
             'uri': 'sc:OthersResearch'},
            {'long':'Publish the results of your research',
             'uri': 'sc:Publish'}]

        # default
        footer = 'You will acknowledge provider in publications reporting use of the materials.'
        legalurl = '/agreements/' + code + "/" + version + '/legalcode'
        
        if code == 'ubmta':
            longname = 'Uniform Biological Material Transfer Agreement'
            conditions = [
                {'long': 'You may not use the materials for clinical purposes.',
                 'code': 'no-clinical',
                 'uri': 'sc:Clinical' },
                {'long': 'You may only use the materials for teaching and academic research.',
                 'code': 'nc',
                 'uri': 'cc:CommercialUse'},
                {'long': 'You may not transfer or distribute the materials, except only Modifications to non-profit organizations under the UBMTA. ',
                 'code': 'no-distribution',
                 'uri': 'sc:Transfer'},
                {'long': 'You will return or destroy materials upon completion of research or expiration of the implementing letter.',
                 'uri': 'sc:Retention',
                 'code': 'return'}]

        if code == 'sla':
            longname = 'Simple Letter Agreement'
            conditions = [
                {'long': 'You may not use the materials for clinical purposes.',
                 'code': 'no-clinical',
                 'uri': 'sc:Clinical'},
                {'long': 'You may only use the materials for teaching and academic research.',
                 'code': 'nc',
                 'uri': 'cc:CommercialUse'},
                {'long': 'You may not transfer or distribute the materials without permission.',
                 'code': 'no-distribution',
                 'uri': 'sc:Transfer'}]

        # must be sc
        splits = code.split('-')
        
        if splits[0] == 'sc':
            longname = 'Science Commons Material Transfer Agreement'

            fieldStr = 'Limited to %s' % kwargs['fieldSpec'] if kwargs.__contains__('fieldSpec') else None;

            footer = ''
            conditions = [
                {'long': 'You may not use the materials for clinical purposes.',
                 'code': 'no-clinical',
                 'uri': 'sc:Clinical'},
                {'long': 'You may not use the materials in connection with the sale of a product or service.',
                 'code': 'nc',
                 'uri': 'cc:CommercialUse'},
                {'long': 'You may not transfer or distribute the materials. ',
                 'code': 'no-distribution',
                 'uri': 'sc:Transfer'}]

            if splits.__contains__('rp'):
                conditions.insert(0, {'long': 'Your use of the materials is restricted to a specific research protocol.',
                                      'code': 'restricted-field',
                                      'extra': fieldStr})
            if splits.__contains__('df'):
                conditions.insert(0, {'long': 'Your use of the materials is restricted by fields of use.',
                                      'code': 'restricted-field',
                                      'extra': fieldStr
                                      })
            if splits.__contains__('ns'):
                conditions.append({'long': 'You may not produce additional quantities of the materials.',
                                   'code': 'no-scaling',
                                   'uri': 'sc:ScalingUp'})
            if splits.__contains__('rd'):
                conditions.append({'long': 'You will return or destroy the materials upon completion of research or the termination of the agreement.',
                                   'uri': 'sc:Retention',
                                   'code': 'return'})

        if kwargs.__contains__('endDate'):
            conditions.append({'long':  'This agreement terminates on %s' % kwargs['endDate'],
                               'code':  'end-date'})

        stream = template.generate(code=code, version=version, permissions=permissions, conditions=conditions, footer=footer, legalurl=legalurl, longname=longname)
        return stream.render("xhtml")