Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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