def wants_plugin(self): """Does this Primitive want to get a plugin instance as its first argument? """ for obj in global_objects.keys(): if self._wants(global_objects[obj].__class__): return True, obj return False, None
def get_name_for_export(self): """ Return the expression (as a string) that represents this Primitive in the exported Python code, e.g., 'turtle.forward'. """ func_name = "" if self.wants_turtle(): func_name = "turtle." elif self.wants_turtles(): func_name = "turtles." elif self.wants_canvas(): func_name = "canvas." elif self.wants_logocode(): func_name = "logo." elif self.wants_heap(): func_name = "logo.heap." elif self.wants_tawindow(): func_name = "tw." else: results, plugin = self.wants_plugin() if results: for k in global_objects.keys(): if k == plugin: if k not in plugins_in_use: plugins_in_use.append(k) func_name = k.lower() + '.' break # get the name of the function directly from the function itself func_name += self.func.__name__ return func_name