本文整理汇总了Python中render.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: display
def display(text):
from data import data
from render import render
s = data['santa']
print text
render(text, s)
开发者ID:alistair-broomhead,项目名称:s3e8,代码行数:7,代码来源:main.py
示例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
开发者ID:ctjprogramming,项目名称:PygameFullscreenToggleDemo,代码行数:30,代码来源:game.py
示例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')
开发者ID:KonceptGeek,项目名称:barnes-hut-sne,代码行数:60,代码来源:bhtsne.py
示例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()
开发者ID:nate-parrott,项目名称:air-traffic-control,代码行数:26,代码来源:game.py
示例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)
开发者ID:azizjiwani,项目名称:dailygraphics,代码行数:57,代码来源:__init__.py
示例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)
开发者ID:abcnews,项目名称:dailygraphics,代码行数:9,代码来源:__init__.py
示例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
开发者ID:clearclaw,项目名称:python-versioneer,代码行数:9,代码来源:test_git.py
示例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))
开发者ID:konfiot,项目名称:PRoq,代码行数:10,代码来源:datatable.py
示例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')
开发者ID:abcnews,项目名称:dailygraphics,代码行数:10,代码来源:__init__.py
示例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)
开发者ID:stlpublicradio,项目名称:dailygraphics,代码行数:55,代码来源:__init__.py
示例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)
开发者ID:abcnews,项目名称:dailygraphics,代码行数:11,代码来源:__init__.py
示例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
开发者ID:filajust,项目名称:cse491-serverz,代码行数:11,代码来源:app.py
示例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)
开发者ID:stlpublicradio,项目名称:dailygraphics,代码行数:52,代码来源:__init__.py
示例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
开发者ID:filajust,项目名称:cse491-serverz,代码行数:13,代码来源:app.py
示例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
开发者ID:whausen,项目名称:part,代码行数:7,代码来源:__init__.py
示例16: image_html
def image_html():
fp = open('./images/justin_eli.jpg', 'rb')
data = fp.read()
fp.close()
html = render.render('image.html').encode('latin-1', 'replace')
return data
开发者ID:filajust,项目名称:cse491-serverz,代码行数:7,代码来源:app.py
示例17: save
def save(self, *args, **kwargs):
if not self.slug:
from pytils.translit import slugify
self.slug = slugify(self.name)
self.text = self.text.strip()
self.html = render(self.text, self.render_method, unsafe=True)
super(Post, self).save(*args, **kwargs)
开发者ID:exezaid,项目名称:Dpress,代码行数:7,代码来源:models.py
示例18: interactive
def interactive( animation, size = 320 ):
basedir = mkdtemp()
basename = join( basedir, 'graph' )
steps = [ Image( path ) for path in render( animation.graphs(), basename, 'png', size ) ]
rmtree( basedir )
slider = widgets.IntSlider( min = 0, max = len( steps ) - 1, step = 1, value = 0 )
return widgets.interactive( lambda n: steps[ n ], n = slider )
开发者ID:mapio,项目名称:GraphvizAnim,代码行数:7,代码来源:jupyter.py
示例19: create
def create():
template = os.path.join(templates_folder, "new.html.mako")
if request.method.lower() == "get":
return render(template=template)
else:
return method_not_supported_message(request.method.lower())
开发者ID:hendychua,项目名称:tusky,代码行数:8,代码来源:user_controller.py
示例20: dij
def dij(graph,src_id,tar_id):
if src_id == tar_id:
return 0
dist = {src_id:0}
c_dist = {src_id:1}
# create a .png state
#prev = {}
Q = BinHeap()
for v in graph.vertList:
if v != src_id:
dist[v] = INFINITE
c_dist[v] = 0
#prev[v] = None
# create a .png state updating the vertex label
Q.insert([v,dist[v]])
#print Q.heapList
#g = Graph()
reng = render.render(graph,dist,c_dist)
sleep(1.25)
while not Q.isEmpty():
u = Q.delMin()
c_dist[u] = 1
reng = render.render(graph,dist,c_dist)
sleep(1.25)
#try to color the deleted vertex
#print u
unb = graph.vertList[u].connectedTo
for nb in unb:
tup = [u,nb]
#print type(unb[nb][0])
alt = dist[u] + unb[nb][0]
if Q.check(nb) :
reng = render.render(graph,dist,c_dist,tup=tup)
if alt < dist[nb]:
#print 'altered',nb,dist[nb],'->',alt
dist[nb] = alt
sleep(1.25)
#reng = render.render(graph,'0')
#prev[nb] = u
Q.editPriority([nb,alt])# changed Q.editPriority([v,alt]) --> ...([nb,alt] )
reng = render.render(graph,dist,c_dist,tup=tup)
开发者ID:seshagiri96,项目名称:graphVisualization,代码行数:46,代码来源:Dijkstra.py
注:本文中的render.render函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论