Trees | Indices | Help |
|
---|
|
1 #-*- coding: utf8 -* 2 # 3 # Max E. Kuznecov ~syhpoon <mek@mek.uz.ua> 2008 4 # 5 6 # This file is part of XYZCommander. 7 # XYZCommander is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU Lesser Public License as published by 9 # the Free Software Foundation, either version 3 of the License, or 10 # (at your option) any later version. 11 # XYZCommander is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU Lesser Public License for more details. 15 # You should have received a copy of the GNU Lesser Public License 16 # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>. 17 18 from libxyz.core.utils import ustring 1921 """ 22 Hooks dispatcher 23 """ 24 27 28 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 297631 """ 32 Register proc to be run upon event occured 33 """ 34 35 if event not in self._data: 36 self._data[event] = [] 37 38 if not callable(proc): 39 xyzlog.error(_(u"HookManager: Callable argument expected")) 40 return False 41 42 self._data[event].append(proc) 43 44 return True45 46 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47 54 55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5658 """ 59 Sequentially run procedures registered with provided event 60 """ 61 62 # No callbacks registered 63 if event not in self._data or not self._data[event]: 64 return False 65 66 for proc in self._data[event]: 67 try: 68 proc(*args) 69 except Exception, e: 70 xyzlog.error( 71 _(u"Error running callback procedure for event %s") % 72 ustring(str(e))) 73 return False 74 75 return True
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jan 17 01:07:08 2010 | http://epydoc.sourceforge.net |