3 @)òfœ ã@s*dgZddlmZmZGdd„deƒZdS)ÚWatcheré)ÚGioÚGLibc@sdeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dS)rcCs"||_||_i|_i|_g|_dS)N)Ú _callbackÚ_timeoutÚ _monitorsÚ _timeoutsÚ_blocked)ÚselfÚcallbackZtimeout©r ú/usr/lib/python3.6/watcher.pyÚ__init__s zWatcher.__init__cCs:tjj|ƒ}|jtjjdƒ|j|<|j|jd|jƒdS)NÚchanged) rÚFileÚ new_for_pathZmonitor_directoryÚFileMonitorFlagsÚNONErÚconnectÚ_file_changed_cb)r Z directoryÚgfiler r r Ú add_watch_dir"s zWatcher.add_watch_dircCs:tjj|ƒ}|jtjjdƒ|j|<|j|jd|jƒdS)Nr) rrrZ monitor_filerrrrr)r Úfilenamerr r r Úadd_watch_file(s zWatcher.add_watch_filecCs |jjƒS)N)rÚkeys)r r r r Ú get_watches.szWatcher.get_watchescCs ||jkS)N)r)r rr r r Ú has_watch1szWatcher.has_watchcCs |j|=dS)N)r)r rr r r Ú remove_watch4szWatcher.remove_watchcCs||jkr|jj|ƒdS)N)r Úappend)r rr r r Ú block_source7s zWatcher.block_sourcecCs||jkr|jj|ƒdS)N)r Úremove)r rr r r Úunblock_source;s zWatcher.unblock_sourcecCs4x.t|jjƒƒD]}tj|j|ƒ|j|=qWdS)N)ÚlistrrrÚ source_remove)r rr r r Úclear_timeouts?szWatcher.clear_timeoutscCs ||jkr|j|ƒ|j|=dS)N)r rr)r rr r r Ú_call_callbackDs  zWatcher._call_callbackcCs¦|jƒ}||jkr8||jkr4tj|j|ƒ|j|=dS|tjjksh|tjjksh|tjj ksh|tjj kr¢||jkrŠtj|j|ƒ|j|=tj |j |j |ƒ|j|<dS)N)Zget_parse_namer rrr#rZFileMonitorEventZCHANGEDZCREATEDZDELETEDZATTRIBUTE_CHANGEDZtimeout_add_secondsrr%)r ZmonitorZgio_fileZgio_other_fileZeventrr r r rIs       zWatcher._file_changed_cbN)Ú__name__Ú __module__Ú __qualname__rrrrrrrr!r$r%rr r r r rsN)Ú__all__Z gi.repositoryrrÚobjectrr r r r Ús