summaryrefslogtreecommitdiff
path: root/ooldtp
diff options
context:
space:
mode:
authorNagappan <nagapan@gmail.com>2010-04-13 01:08:33 -0700
committerNagappan <nagapan@gmail.com>2010-04-13 01:08:33 -0700
commit013692654065af9a83de517d76b3e3ef6da24f65 (patch)
treebcfb2b6a846975de483ba88d00ef920628aef493 /ooldtp
parent915f62d5410c1f3cad3555e5ba795ed43c4d929b (diff)
Added DEBUG info
Diffstat (limited to 'ooldtp')
-rw-r--r--ooldtp/_context.py40
1 files changed, 26 insertions, 14 deletions
diff --git a/ooldtp/_context.py b/ooldtp/_context.py
index 4cbd0a2..8fd7677 100644
--- a/ooldtp/_context.py
+++ b/ooldtp/_context.py
@@ -17,8 +17,14 @@ See "COPYING" in the source distribution for more information.
Headers in this file shall remain intact.
'''
+import os
import ldtp
+if os.environ.has_key('LDTP_DEBUG'):
+ _ldtp_debug = os.environ['LDTP_DEBUG']
+else:
+ _ldtp_debug = None
+
class _Wrapper(object):
def __new__(cls, *args, **kwargs):
if not cls._generated:
@@ -26,12 +32,14 @@ class _Wrapper(object):
d = ldtp.__dict__
cls._wrapped_methods =[]
for attr in d:
- if cls._isRemoteMethod(d[attr]) and cls._isRelevant(d[attr]):
+ if cls._isRemoteMethod(d[attr]):
setted = attr
if hasattr(cls, attr):
setted = "_remote_"+setted
cls._wrapped_methods.append(setted)
setattr(cls, setted, d[attr])
+ elif _ldtp_debug:
+ print '*NOT* RELEVANT method', attr
return object.__new__(cls)
def __getattribute__(self, name):
@@ -43,6 +51,7 @@ class _Wrapper(object):
def _isRemoteMethod(cls, obj):
return hasattr(obj, '_Method__name')
+
_isRemoteMethod = classmethod(_isRemoteMethod)
def _listArgs(cls, func):
@@ -50,6 +59,7 @@ class _Wrapper(object):
l = filter(lambda x: x.startswith('@param '), l)
l = [x[7:].split(':')[0] for x in l]
return l
+
_listArgs = classmethod(_listArgs)
class Context(_Wrapper):
@@ -67,8 +77,21 @@ class Context(_Wrapper):
def _isRelevant(cls, obj):
args = cls._listArgs(obj)
return args and 'window_name' == args[0]
+
_isRelevant = classmethod(_isRelevant)
+ def getchild(self, child_name='', role=''):
+ # TODO: Bad API choice. Inconsistent, should return object or list,
+ # not both. UPDATE: Only returns first match.
+ matches = self._remote_getchild(child_name, role, True)
+ if matches:
+ if role:
+ return [Component(self._window_name, matches[0])]
+ else:
+ return Component(self._window_name, matches[0])
+ else:
+ return None
+
class _ContextFuncWrapper:
def __init__(self, window_name, func):
self._window_name = window_name
@@ -87,18 +110,6 @@ class Component(_Wrapper):
def getName(self):
return self._object_name
- def getchild(self, child_name='', role=''):
- # TODO: Bad API choice. Inconsistent, should return object or list,
- # not both. UPDATE: Only returns first match.
- matches = self._remote_getchild(child_name, role, True)
- if matches:
- if role:
- return [Component(self._window_name, matches[0])]
- else:
- return Component(self._window_name, matches[0])
- else:
- return None
-
def __repr__(self):
return 'Component "%s" in "%s"' % \
(self._object_name, self._window_name)
@@ -111,8 +122,9 @@ class Component(_Wrapper):
args = cls._listArgs(obj)
return len(args) >= 2 and \
'window_name' == args[0] and 'object_name' == args[1]
+
_isRelevant = classmethod(_isRelevant)
-
+
class _ComponentFuncWrapper:
def __init__(self, window_name, object_name, func):
self._window_name = window_name