def get(self, id): individual = model.Individual.get_by_id(int(id)) if not individual: self.error(404) return parents = ndb.get_multi(individual.parents) children = model.Individual.query(model.Individual.parents == individual.key).fetch() genome = genome_repr(individual.genome) expression = piclang.stackparse(individual.genome) self.render_template('individual.html', individual=individual, genome=genome, expression=expression, children=children, parents=parents)
def get(self, id): individual = model.Individual.get_by_id(int(id)) if not individual: self.error(404) return parents = ndb.get_multi(individual.parents) children = model.Individual.query( model.Individual.parents == individual.key).fetch() genome = genome_repr(individual.genome) expression = piclang.stackparse(individual.genome) self.render_template('individual.html', individual=individual, genome=genome, expression=expression, children=children, parents=parents)
def create(cls, genome, generation, parents, store=False): fun = piclang.stackparse(genome, normalize=True) if piclang.is_atom(fun): return None image = piclang.render(fun, points=8192) if not image: return None filename = files.blobstore.create(mime_type='image/png') with files.open(filename, 'a') as f: image.save(f, "PNG") files.finalize(filename) blob_key = files.blobstore.get_blob_key(filename) individual = cls(genome=genome, generation=generation, parents=parents, image=blob_key) if store: individual.put() return individual
def create(cls, genome, generation, parents, store=False): fun = piclang.stackparse(genome, normalize=True) if piclang.is_atom(fun): return None image = piclang.render(fun, points=8192) if not image: return None filename = files.blobstore.create(mime_type='image/png') with files.open(filename, 'a') as f: image.save(f, "PNG") files.finalize(filename) blob_key = files.blobstore.get_blob_key(filename) individual = cls( genome=genome, generation=generation, parents=parents, image=blob_key ) if store: individual.put() return individual