home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / util / observe / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  1.2 KB  |  44 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from observable import *
  5. from observabledict import *
  6. from observablelist import *
  7. from observableproperty import *
  8.  
  9. def clear_all():
  10.     import gc
  11.     count = 0
  12.     for obj in gc.get_objects():
  13.         
  14.         try:
  15.             observers = getattr(obj, 'observers', None)
  16.             clear = getattr(observers, 'clear', None)
  17.             if clear is not None:
  18.                 clear()
  19.                 count += 1
  20.         continue
  21.         continue
  22.  
  23.     
  24.     return count
  25.  
  26. import logging
  27.  
  28. def add_observers(obj, argslist):
  29.     for func, attr in argslist:
  30.         if not hasattr(obj, attr):
  31.             logging.critical('%s has no attribute %s to observe!', obj.__class__.__name__, attr)
  32.             continue
  33.         obj.add_observer(func, attr)
  34.     
  35.  
  36. if __name__ == '__main__':
  37.     import doctest
  38.     import unittest
  39.     import observable
  40.     suite = unittest.TestSuite()
  41.     suite.addTest(doctest.DocTestSuite(observable))
  42.     unittest.TextTestRunner().run(suite)
  43.  
  44.