Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.90 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #   protofilter.py
  5. #      
  6. #   Copyright 2011 Sergio López <sergio.lopez@drainware.com>
  7. #      
  8. #   This program is free software; you can redistribute it and/or modify
  9. #   it under the terms of the GNU General Public License as published by
  10. #   the Free Software Foundation; either version 2 of the License, or
  11. #   (at your option) any later version.
  12. #      
  13. #   This program is distributed in the hope that it will be useful,
  14. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #   GNU General Public License for more details.
  17. #      
  18. #   You should have received a copy of the GNU General Public License
  19. #   along with this program; if not, write to the Free Software
  20. #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. #   MA 02110-1301, USA.
  22.  
  23. #   Sintaxis General:
  24. #       dwf = drainware función/método
  25. #       dwv = drainware variable
  26. #       dwl = drainware lista
  27. #       dwc = drainware clase
  28. #
  29. #       dw?+Utilidad
  30. #
  31. #   Sintaxis Debug:
  32. #       #DBG+" "
  33.  
  34. """
  35. * Protofilter version 22feb2011
  36. """
  37. try:
  38.     import sys
  39. except ImportError:
  40.     exit(1)
  41.    
  42. # Funciones
  43. # ----------------------------------------------------------------------
  44.  
  45. def dwfGestorArgumentos():
  46.     """dwfGestorArgumentos: Gestiona argumentos del programa.
  47.         retorna lista de argumentos (1:)
  48.     """
  49.     dwlRetorno = list()
  50.     dwvContadorArgumentos = len(sys.argv)
  51.     #DBG print dwvContadorArgumentos
  52.     if dwvContadorArgumentos < 3:
  53.         print "Error: No arguments"
  54.         exit(1)
  55.     else:
  56.         for i in sys.argv[1:]:
  57.             dwlRetorno.append(i)
  58.     return dwlRetorno
  59.    
  60. # ----------------------------------------------------------------------
  61.  
  62.  
  63. # Clase principal del programa
  64. # ----------------------------------------------------------------------
  65.  
  66. class dwcMain():
  67.     """
  68.         * Clase principal del programa
  69.         * Administra las acciones
  70.     """
  71.     def __init__(self, dwlArgumentos):
  72.         self.dwlArgumentos = dwlArgumentos
  73.         self.dwvAccion = self.dwlArgumentos[0]
  74.         self.dwlElementos = list()
  75.        
  76.         for self.i in self.dwlArgumentos[1:]:
  77.             self.dwlElementos.append(self.i)
  78.            
  79.         #DBG print "Debug: Acción:", self.dwvAccion
  80.         #DBG print "Debug: Elementos:", self.dwlElementos
  81.        
  82.         self.dwfLanzadera()
  83.        
  84.     def dwfLanzadera(self):
  85.         """
  86.             * Llama a métodos dependiendo de la acción
  87.         """
  88.         if self.dwvAccion == "on":
  89.             pass ############################ Implementar métodos
  90.         elif self.dwvAccion == "off":
  91.             pass
  92.         elif self.dwvAccion == "status":
  93.             pass
  94.         else:
  95.             print "Error:",self.dwvAccion,"no es un atributo válido."
  96.             exit(1)
  97.  
  98. # ----------------------------------------------------------------------
  99. def main(dwlEntrada):
  100.     dwlArgumentos = list() # Lista final de argumentos
  101.    
  102.     for i in dwlEntrada:
  103.         dwlArgumentos.append(str(i.lower()))
  104.        
  105.     x = dwcMain(dwlArgumentos)
  106.     return 0
  107.  
  108. if __name__ == '__main__':
  109.     main(dwfGestorArgumentos())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement