Ejemplo n.º 1
0
def process(jinja, path):
    try:
        headers, content = util.read_header_file(path)
    except:
        print "when processing '%s':" % path
        raise

    html = markdown.markdown(content.decode('utf-8'),
                             extensions=['smarty'],
                             extension_configs={
                                 'smarty': {
                                     'smart_quotes': False,
                                     'smart_ellipses': False,
                                     'substitutions': {
                                         'ndash': '—',
                                     },
                                 }
                             }).encode('utf-8')
    attrs = {
        'content': html,
        'root': '../' * (path.count('/') - 1),
    }
    attrs.update(headers)

    output = jinja.get_template('page.tmpl').render(**attrs)

    output_path = os.path.splitext(path)[0] + '.html'
    util.write_if_changed(output_path, output)
Ejemplo n.º 2
0
Archivo: blog.py Proyecto: rob-opsi/cms
def load_post(path):
    headers, content = util.read_header_file(path)

    timestamp = datetime.datetime.strptime(headers['timestamp'],
                                           '%Y/%m/%d %H:%M')
    #timestamp += datetime.timedelta(seconds=time.timezone)
    html = markdown.markdown(content.decode('utf-8'),
                             extensions=['smarty'],
                             extension_configs={
                                 'smarty': {
                                     'smart_quotes': False,
                                     'smart_ellipses': False,
                                     'substitutions': {
                                         'ndash': '—',
                                     },
                                 }
                             }).encode('utf-8')

    path = (timestamp.strftime('%Y/%m') + '/' +
            os.path.splitext(os.path.basename(path))[0] + '.html')
    return Post(title=headers['subject'],
                timestamp=timestamp,
                path=path,
                content=html.decode('utf-8'),
                summary=headers.get('summary', ''))
Ejemplo n.º 3
0
def main(args):
	ret = util.read_header_file(args.header)
	data = run_compute_surface(ret['mask'], args.normal_map)

	depth_map = scipy.misc.toimage(data)
	# albedo_map = scipy.misc.toimage(data[1])

	depth_map.save(args.output_format % "depth")
def main(args):
    ret = util.read_header_file(args.header)
    data = unknown_light_photometric_stereo(ret["images"], ret["mask"])

    normal_map = scipy.misc.toimage(data[0])
    albedo_map = scipy.misc.toimage(data[1])

    normal_map.save(args.output_format % "normal")
    albedo_map.save(args.output_format % "albedo")
def main(args):
	ret = util.read_header_file(args.header)
	data = unknown_light_photometric_stereo(ret["images"], ret["mask"])

	normal_map = scipy.misc.toimage(data[0])
	albedo_map = scipy.misc.toimage(data[1])

	normal_map.save(args.output_format % "normal")
	albedo_map.save(args.output_format % "albedo")
def main(args):
    ret = util.read_header_file(args.header)
    light_directions = compute_light_directions(ret['images'], ret['mask'])

    with open(args.output_file, 'w') as output_file:
        output_file.write('Header: %s\n' % args.header)
        output_file.write('%d\n' % len(light_directions))
        for light in light_directions:
            output_file.write('%lf %lf %lf\n' % (light[0], light[1], light[2]))
def main(args):
	ret = util.read_header_file(args.header)
	light_directions = compute_light_directions(ret['images'], ret['mask'])

	with open(args.output_file, 'w') as output_file:
		output_file.write('Header: %s\n'%args.header)
		output_file.write('%d\n'%len(light_directions))
		for light in light_directions:
			output_file.write('%lf %lf %lf\n' % (light[0], light[1], light[2]))
Ejemplo n.º 8
0
Archivo: cms.py Proyecto: evmar/cms
def process(default_template, path):
    try:
        headers, content = util.read_header_file(path)
    except:
        print "when processing '%s':" % path
        raise

    mtime = time.localtime(os.path.getmtime(path))

    attrs = {'content': markdown.markdown(content),
             'lastupdate': time.strftime('%Y-%m-%d', mtime),
             'root': '../' * (path.count('/') - 1)}
    attrs.update(headers)

    output = default_template.evaluate(attrs)

    output_path = os.path.splitext(path)[0] + '.html'
    util.write_if_changed(output_path, output)