Esempio n. 1
0
    def ayuda(self, comando=None):
        """
        Retorna la lista de comandos disponibles.

        comando -- Comando del que se desea obtener ayuda (opcional).
        """
        if comando in self.comandos:
            salida = strip(self.comandos[comando].__doc__)
        else:
            salida = "Sintaxis: comando [parámetro1] [parámetro2] [..]\n" + \
                     "Comandos: " + \
                     ", ".join(sorted(self.comandos.keys()))
        return salida
Esempio n. 2
0
 def __init__(self):
     """Constructor: Inicializa propiedades de instancia y ciclo REPL."""
     self.comandos = {
         "agregar": self.agregar,
         "borrar": self.borrar,
         "mostrar": self.mostrar,
         "listar": self.listar,
         "buscar": self.buscar,
         "ayuda": self.ayuda,
         "salir": self.salir
     }
     archivo = "institutos.db"
     introduccion = strip(__doc__)
     self.varinstitutos = Estante(archivo)
     if not self.varinstitutos.esarchivo():
         introduccion += '\nError: No se pudo abrir "{}"'.format(archivo)
     REPL(self.comandos, introduccion).ciclo()