本文整理汇总了Python中render.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
def display(text):
from data import data
from render import render
s = data['santa']
print text
render(text, s)
示例2: main
def main():
pygame.init()
globals.pygame = pygame # assign global pygame for other modules to reference
globals.inputs = Inputs(pygame) # assign global inputs for other modules to reference
update_display_mode() # now that the global display properties have been set up, update the display
clock = pygame.time.Clock() # clock to tick / manage delta
entities = [] # contains every object that will be drawn in the game
entities.append(Entity()) # our testing entity will be the default entity
loop = True # for controlling the game loop
while(loop):
clock.tick(60) # tick the clock with a target 60 fps
globals.window.fill((255, 255, 255))
globals.inputs.update() # refresh inputs
update(entities) # update all entities
render(entities) # draw all entities
if(globals.inputs.isKeyDown("space")): toggle_fullscreen() # space bar toggles fullscreen
if(globals.inputs.isKeyDown("escape")): loop = False # escape key exits game
if(globals.inputs.isQuitPressed()): loop = False # red 'x' button exits game
pygame.display.flip() # flip the display, which finally shows our render
pygame.quit() # unload pygame modules
示例3: main
def main(args):
argp = _argparse().parse_args(args[1:])
# Read the data
data = []
titles = []
#gzipFile = gzip.open("data/english-embeddings.turian.txt.gz")
#for line in gzipFile:
# tokens = string.split(line)
# titles.append(tokens[0])
# data.append([float(f) for f in tokens[1:]])
#data = numpy.array(data)
print "Reading Data"
lensingJson = featureExtraction.readData('data/fullData.json')
#ExtractBagOfWord features
print "Extracting Features"
data = featureExtraction.extBagOfWordFeatures(lensingJson)
for i in range(0,len(lensingJson)):
titles.append(str(i))
#Call PCA
#data = PCA(data,30)
#print "PCA Complete"
#call bh_tsne and get the results. Zip the titles and results for writing
result = bh_tsne(data, perplexity=argp.perplexity, theta=argp.theta,
verbose=argp.verbose)
#render image
if argp.render:
print "Rendering Image"
import render
render.render([(title, point[0], point[1]) for title, point in zip(titles, result)], "output/lensing500p30-data.rendered.png", width=3000, height=1800)
#convert result into json and write it
if argp.write:
print "Writing data to file"
resData = {}
minx = 0
maxx = 0
miny = 0
maxy = 0
for (title,result) in zip(titles,[[res[0],res[1]] for res in result]):
resData[title] = {'x':result[0], 'y':result[1]}
if minx > result[0]: minx = result[0]
if maxx < result[0]: maxx = result[0]
if miny > result[1]: miny = result[1]
if maxy < result[1]: maxy = result[1]
print "creating json"
print len(resData)
jsonStr = json.dumps(resData)
print "MinX - %s MaxX - %s MinY - %s MaxY - %s" % (minx, maxx, miny, maxy)
with open('output/coordinateslensing-full-srl-p40.json','w') as outFile:
outFile.write("jsonstr = ");
outFile.write(jsonStr+'\n')
示例4: run
def run(self):
pygame.init()
self.clock = pygame.time.Clock()
aspect = self.map['width']*1.0/self.map['height']
self.w = 700
self.h = int(self.w/aspect)
self.surface = pygame.display.set_mode((self.w, self.h))
self.planes = []
self.planes.append(plane.Plane(self))
while True:
dt = 1.0/FRAME_RATE
# handle events:
for event in pygame.event.get():
if event.type == pygame.QUIT:
break
# make new planes:
if random.random() < dt * NEW_PLANES_PER_SECOND:
self.planes.append(plane.Plane(self))
# update existing planes:
for p in self.planes:
p.advance(dt)
# render graphics:
render.render(self)
pygame.display.update()
self.clock.tick(FRAME_RATE)
pygame.quit()
示例5: deploy
def deploy(slug):
"""
Deploy the latest app to S3 and, if configured, to our servers.
"""
require('settings', provided_by=[production, staging])
if not slug:
print 'You must specify a project slug, like this: "deploy:slug"'
return
graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
graphic_assets = '%s/assets' % graphic_root
s3_assets = '%s/assets' % s3_root
graphic_config = load_graphic_config(graphic_root)
use_assets = getattr(graphic_config, 'USE_ASSETS', True)
default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE
update_copy(slug)
if use_assets:
assets.sync(slug)
render.render(slug)
flat.deploy_folder(
graphic_root,
s3_root,
headers={
'Cache-Control': 'max-age=%i' % default_max_age
},
ignore=['%s/*' % graphic_assets]
)
# Deploy parent assets
flat.deploy_folder(
'www',
app_config.PROJECT_SLUG,
headers={
'Cache-Control': 'max-age=%i' % default_max_age
}
)
if use_assets:
flat.deploy_folder(
graphic_assets,
s3_assets,
headers={
'Cache-Control': 'max-age=%i' % assets_max_age
}
)
print ''
print '%s URL: %s/graphics/%s/' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
示例6: update_from_template
def update_from_template(slug, template):
require('settings', provided_by=[production, staging])
if not slug:
print 'You must specify a project slug and template, like this: "update_from_template:slug,template=template"'
return
recopy_templates(slug, template)
render.render(slug)
示例7: do_render
def do_render(self, pieces):
out = {}
for style in ["pep440", "pep440-pre", "pep440-post", "pep440-old",
"pep440-bare", "git-describe", "git-describe-long"]:
out[style] = render(pieces, style)["version"]
DEFAULT = "pep440"
self.assertEqual(render(pieces, ""), render(pieces, DEFAULT))
self.assertEqual(render(pieces, "default"), render(pieces, DEFAULT))
return out
示例8: update
def update(self, data) :
surface = pygame.Surface((self.width, self.height))
surface.fill(self.back_color)
for i in range(len(data)) :
col = i % self.cols
row = int(i / self.cols)
surface.blit(data[i]["image"], data[i]["image"].get_rect(top = (row * self.item_height) + self.gap_y, left = (col * self.item_width)))
render.render(data[i]["data"], self.font, surface, self.front_color, (col * self.item_width) + data[i]["image"].get_width() + self.gap_x, (row * self.item_height) + self.gap_y, self.item_width - data[i]["image"].get_width() - (2*self.gap_x), self.item_height - self.gap_y)
self.background.blit(surface, pygame.Rect(self.left, self.top, self.width, self.height))
示例9: update_from_content
def update_from_content(slug):
require('settings', provided_by=[production, staging])
if not slug:
print 'You must specify a project slug, like this: "update_from_content:slug"'
return
update_copy(slug)
render.render(slug)
write_meta_json(slug, 'content')
示例10: deploy_single
def deploy_single(path):
"""
Deploy a single project to S3 and, if configured, to our servers.
"""
require('settings', provided_by=[production, staging])
slug, abspath = utils.parse_path(path)
graphic_root = '%s/%s' % (abspath, slug)
s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug)
graphic_assets = '%s/assets' % graphic_root
s3_assets = '%s/assets' % s3_root
graphic_node_modules = '%s/node_modules' % graphic_root
graphic_config = load_graphic_config(graphic_root)
use_assets = getattr(graphic_config, 'USE_ASSETS', True)
default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE
assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE
update_copy(path)
if use_assets:
error = assets.sync(path)
if error:
return
render.render(path)
flat.deploy_folder(
graphic_root,
s3_root,
headers={
'Cache-Control': 'max-age=%i' % default_max_age
},
ignore=['%s/*' % graphic_assets, '%s/*' % graphic_node_modules,
# Ignore files unused on static S3 server
'*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak',
'%s/base_template.html' % graphic_root,
'%s/child_template.html' % graphic_root,
'%s/README.md' % graphic_root]
)
if use_assets:
flat.deploy_folder(
graphic_assets,
s3_assets,
headers={
'Cache-Control': 'max-age=%i' % assets_max_age
},
ignore=['%s/private/*' % graphic_assets]
)
# Need to explicitly point to index.html for the AWS staging link
file_suffix = ''
if env.settings == 'staging':
file_suffix = 'index.html'
print ''
print '%s URL: %s/graphics/%s/%s' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug, file_suffix)
示例11: debug_deploy
def debug_deploy(slug, template):
require('settings', provided_by=[production, staging])
if not slug:
print 'You must specify a project slug and template, like this: "debug_deploy:slug,template=template"'
return
recopy_templates(slug, template)
# update_copy(slug)
# write_meta_json(slug, 'content')
render.render(slug)
示例12: urlencoded_html
def urlencoded_html(form):
# query_string = environ['QUERY_STRING']
if 'firstname' not in form or 'lastname' not in form:
html = render.render('error.html').encode('latin-1', 'replace')
else:
vars_dict = {'firstname': form['firstname'].value,\
'lastname': form['lastname'].value}
html = render.render('urlencoded.html', vars_dict).encode('latin-1', 'replace')
return html
示例13: clone_graphic
def clone_graphic(old_slug, slug=None):
"""
Clone an existing graphic creating a new spreadsheet
"""
if not slug:
slug = _create_slug(old_slug)
if slug == old_slug:
print "%(slug)s already has today's date, please specify a new slug to clone into, i.e.: fab clone_graphic:%(slug)s,NEW_SLUG" % {'slug': old_slug}
return
# Add today's date to end of slug if not present or invalid
slug = _add_date_slug(slug)
graphic_path = '%s/%s' % (app_config.GRAPHICS_PATH, slug)
if _check_slug(slug):
return
# First search over the graphics repo
clone_path, old_graphic_warning = _search_graphic_slug(old_slug)
if not clone_path:
print 'Did not find %s on graphics repos...skipping' % (old_slug)
return
local('cp -r %s %s' % (clone_path, graphic_path))
config_path = os.path.join(graphic_path, 'graphic_config.py')
if os.path.isfile(config_path):
print 'Creating spreadsheet...'
success = copy_spreadsheet(slug)
if success:
download_copy(slug)
else:
local('rm -r %s' % (graphic_path))
print 'Failed to copy spreadsheet! Try again!'
return
else:
print 'No graphic_config.py found, not creating spreadsheet'
# Force render to clean up old graphic generated files
render.render(slug)
print 'Run `fab app` and visit http://127.0.0.1:8000/graphics/%s to view' % slug
if old_graphic_warning:
print "WARNING: %s was found in old & dusty graphic archives\n"\
"WARNING: Please ensure that graphic is up-to-date"\
" with your current graphic libs & best-practices" % (old_slug)
示例14: submit_html
def submit_html(environ):
query = environ['QUERY_STRING']
html = ''
res = urlparse.parse_qs(query)
if len(res) < 2: # check if the input was valid
html = render.render('error.html').encode('latin-1', 'replace')
else:
vars_dict = {'firstname': res['firstname'][0],
'lastname': res['lastname'][0]}
html = render.render('submit.html', vars_dict).encode('latin-1', 'replace')
return html
示例15: markdown_to_plain_text
def markdown_to_plain_text(markup, safe_mode='escape'):
html = render(markup, substitutions=False, safe_mode=safe_mode)
try:
return fragment_fromstring(html, create_parent=True).text_content()
except Exception, e:
log.exception(e)
return markup