#NEWLINE# def add_observer( self , observer ) : #NEWLINE# #INDENT# '\n        Spawns thread or adds IOPSNotificationCreateRunLoopSource directly to provided cf_run_loop\n        @see: __init__\n        ' #NEWLINE# super ( PowerManagement , self ) . add_observer ( observer ) #NEWLINE# if ( len ( self . _weak_observers ) == 1 ) : #NEWLINE# #INDENT# if ( not self . _cf_run_loop ) : #NEWLINE# #INDENT# PowerManagement . notifications_observer . addObserver ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# @ objc . callbackFor ( IOPSNotificationCreateRunLoopSource ) #NEWLINE# def on_power_sources_change( context ) : #NEWLINE# #INDENT# self . on_power_source_notification ( ) #NEWLINE# #UNINDENT# self . _source = IOPSNotificationCreateRunLoopSource ( on_power_sources_change , None ) #NEWLINE# CFRunLoopAddSource ( self . _cf_run_loop , self . _source , kCFRunLoopDefaultMode )