Advertisement
Guest User

para_o_gnal

a guest
Oct 24th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. class ADict(dict):
  2.     __setattr__ = dict.__setitem__
  3.     __delattr__ = dict.__delitem__
  4.     __getattr__ = dict.get
  5.  
  6. LibEmpresa = ADict()
  7.  
  8. def importar(empresa):
  9.     libsImport = dict(
  10.         Gol=dict(
  11.                 module='Gol.WSClient.SessionManagerClient_client',
  12.                 methodsDePara={
  13.                     "SMLocator": "SessionManagerClientLocator"
  14.                 }
  15.         ),
  16.         Azul=dict(
  17.             module='Azul.WSClient.BWS_client',
  18.             methodsDePara={
  19.                     "SMLocator": "BWSLocator"
  20.             }
  21.         ),
  22.     )
  23.     global LibEmpresa
  24.     inf = libsImport[empresa]
  25.     c = __import__(inf['module'])
  26.     for i in dir(c):
  27.         LibEmpresa[i] = getattr(c, i)
  28.     for m in inf['methodsDePara']:
  29.         LibEmpresa[m] = getattr(c, inf['methodsDePara'][m])
  30.  
  31. importar('Gol')
  32.  
  33. LibEmpresa.SMLocator(.....)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement