Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # protofilter.py
- #
- # Copyright 2011 Sergio López <sergio.lopez@drainware.com>
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- # Sintaxis General:
- # dwf = drainware función/método
- # dwv = drainware variable
- # dwl = drainware lista
- # dwc = drainware clase
- #
- # dw?+Utilidad
- #
- # Sintaxis Debug:
- # #DBG+" "
- """
- * Protofilter version 22feb2011
- """
- try:
- import sys
- except ImportError:
- exit(1)
- # Funciones
- # ----------------------------------------------------------------------
- def dwfGestorArgumentos():
- """dwfGestorArgumentos: Gestiona argumentos del programa.
- retorna lista de argumentos (1:)
- """
- dwlRetorno = list()
- dwvContadorArgumentos = len(sys.argv)
- #DBG print dwvContadorArgumentos
- if dwvContadorArgumentos < 3:
- print "Error: No arguments"
- exit(1)
- else:
- for i in sys.argv[1:]:
- dwlRetorno.append(i)
- return dwlRetorno
- # ----------------------------------------------------------------------
- # Clase principal del programa
- # ----------------------------------------------------------------------
- class dwcMain():
- """
- * Clase principal del programa
- * Administra las acciones
- """
- def __init__(self, dwlArgumentos):
- self.dwlArgumentos = dwlArgumentos
- self.dwvAccion = self.dwlArgumentos[0]
- self.dwlElementos = list()
- for self.i in self.dwlArgumentos[1:]:
- self.dwlElementos.append(self.i)
- #DBG print "Debug: Acción:", self.dwvAccion
- #DBG print "Debug: Elementos:", self.dwlElementos
- self.dwfLanzadera()
- def dwfLanzadera(self):
- """
- * Llama a métodos dependiendo de la acción
- """
- if self.dwvAccion == "on":
- pass ############################ Implementar métodos
- elif self.dwvAccion == "off":
- pass
- elif self.dwvAccion == "status":
- pass
- else:
- print "Error:",self.dwvAccion,"no es un atributo válido."
- exit(1)
- # ----------------------------------------------------------------------
- def main(dwlEntrada):
- dwlArgumentos = list() # Lista final de argumentos
- for i in dwlEntrada:
- dwlArgumentos.append(str(i.lower()))
- x = dwcMain(dwlArgumentos)
- return 0
- if __name__ == '__main__':
- main(dwfGestorArgumentos())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement