Author: dmeyer
Date: Sun Mar 2 11:41:30 2008
New Revision: 3147
Log:
add import helper for files with name conflict
Modified:
trunk/base/src/notifier/thread.py
trunk/base/src/utils.py
Modified: trunk/base/src/notifier/thread.py
==============================================================================
--- trunk/base/src/notifier/thread.py (original)
+++ trunk/base/src/notifier/thread.py Sun Mar 2 11:41:30 2008
@@ -66,6 +66,10 @@
from signals import Signal
from async import InProgress
+# import python thread file
+from kaa.utils import importhelper
+thread = importhelper('thread')
+
# get logging object
log = logging.getLogger('notifier')
@@ -139,7 +143,7 @@
# decorator in classes
self._lock = None
return
- if isinstance(obj, threading._RLock):
+ if isinstance(obj, (threading._RLock, thread.LockType)):
# decorator from functions
self._lock = obj
return
Modified: trunk/base/src/utils.py
==============================================================================
--- trunk/base/src/utils.py (original)
+++ trunk/base/src/utils.py Sun Mar 2 11:41:30 2008
@@ -34,6 +34,7 @@
import os
import stat
import time
+import imp
import logging
import kaa
@@ -281,3 +282,22 @@
def getter(self, fget):
return self._add_doc(property(fget, self.fset, self.fdel),
fget.__doc__ or self.fget.__doc__)
+
+
+def importhelper(name):
+ """
+ Help to import modules with name conflict. E.g. thread.py in notifier
+ uses importhelper('thread').
+ """
+ # Fast path: see if the module has already been imported.
+ try:
+ return sys.modules[name]
+ except KeyError:
+ pass
+ fp, pathname, description = imp.find_module(name)
+ try:
+ return imp.load_module(name, fp, pathname, description)
+ finally:
+ # Since we may exit via an exception, close fp explicitly.
+ if fp:
+ fp.close()
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog