コード例 #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)
コード例 #2
0
ファイル: blog.py プロジェクト: 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', ''))
コード例 #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")
コード例 #4
0
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")
コード例 #6
0
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]))
コード例 #7
0
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]))
コード例 #8
0
ファイル: cms.py プロジェクト: 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)