Atix24

Page 44

operaciondocumento.py import time from random import randint def documento (): a = randint(1,3) if a == 1: td='Formulario de Solicitud' elif a == 2: td='Expediente Cliente' elif a == 3: td='Certtificado de Inscripcion' return td def operacion (): b = randint(1,3) if b == 1: ops='Generar' elif b == 2: ops='Imprimir' elif b == 3: ops='Registrar' return ops def paginas(): return randint(1,10) def ejecutar(trabajo): if trabajo.operacion == 'Generar': print('Generando %s ...' % trabajo.documento) time.sleep(2) print('Hecho!') elif trabajo.operacion == 'Imprimir': print('Imprimiendo %s ...' % trabajo.documento) time.sleep(2) print('Hecho!') elif trabajo.operacion == 'Registrar': print('Registrando %s ...' % trabajo.documento) time.sleep(2) print('Hecho!') else: raise NotImplementedError('Operaciรณn "%s" no soportada.' % trabajo.operacion)

trabajo.py import json class Trabajo: def __init__(self, self.operacion self.documento self.paginas =

operacion, documento, paginas=None): = operacion = documento paginas

def exportar(self): return json.dumps(self.__dict__) @classmethod def importar(cls, datos): dic = json.loads(datos) return cls(dic['operacion'], dic['documento'], dic['paginas'])


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.