home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / services / service_component.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  2.7 KB  |  75 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import cPickle
  5. import common
  6.  
  7. class ServiceComponent(object):
  8.     _attrfields_ = [
  9.         ('protocol', 'protocol'),
  10.         ('name', 'username'),
  11.         ('password', 'password_crypted'),
  12.         ('id', 'id')]
  13.     _datafields_ = []
  14.     
  15.     def deserialize(cls, netacct):
  16.         attrs = { }
  17.         msc = common.protocolmeta.get(netacct.protocol)
  18.         subcls = hooks.first('digsby.services.component.%s.factory' % msc.component_type, impls = (msc.service_provider, 'default'))
  19.         attrs['provider_id'] = msc.service_provider
  20.         attrs['component_type'] = msc.component_type
  21.         
  22.         default = lambda k: msc.info.defaults.get(k, sentinel)
  23.         for netkey, mykey in subcls._attrfields_:
  24.             attrs[mykey] = getattr(netacct, netkey)
  25.         
  26.         options = cPickle.loads(netacct.data)
  27.         for netkey, mykey in subcls._datafields_:
  28.             val = options.get(netkey)
  29.             if val is None:
  30.                 val = default(netkey)
  31.                 if val is sentinel:
  32.                     raise KeyError('%r is required but is not present.', netkey)
  33.                 val is sentinel
  34.             
  35.             attrs[mykey] = val
  36.         
  37.         return subcls(attrs)
  38.  
  39.     deserialize = classmethod(deserialize)
  40.     
  41.     def serialize(self):
  42.         attrs = { }
  43.         for netkey, mykey in self._attrfields_:
  44.             attrs[netkey] = getattr(self, mykey)
  45.         
  46.         options = { }
  47.         for netkey, mykey in self._datafields_:
  48.             options[netkey] = getattr(self, mykey)
  49.         
  50.         attrs['data'] = cPickle.dumps(options)
  51.         return attrs
  52.  
  53.     
  54.     def __init__(self, **options):
  55.         if options:
  56.             self.init(options)
  57.         
  58.  
  59.     
  60.     def init(self, options):
  61.         for k, v in options.items():
  62.             setattr(self, k, v)
  63.         
  64.  
  65.     
  66.     def _get_password(self):
  67.         return common.profile.plain_pw(self.password_crypted)
  68.  
  69.     
  70.     def _set_password(self, val):
  71.         self.password_crypted = common.profile.crypt_pw(val)
  72.  
  73.     password = property(_get_password, _set_password)
  74.  
  75.