diff options
author | Eitan Isaacson <eitan@sparky.(none)> | 2009-04-28 16:09:23 +0300 |
---|---|---|
committer | Eitan Isaacson <eitan@sparky.(none)> | 2009-04-28 16:09:23 +0300 |
commit | f6e5940dc19d3b7598483a1431d5207de52a149a (patch) | |
tree | 1cb99a846ffb283d85f3ef9ae16290b23881b4b0 /ooldtp | |
parent | 5411f5a3fa66dde973091cb775c0a0c2d4ff5b49 (diff) |
Initial ooldtp
Diffstat (limited to 'ooldtp')
-rw-r--r-- | ooldtp/__init__.py | 4 | ||||
-rw-r--r-- | ooldtp/_context.py | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/ooldtp/__init__.py b/ooldtp/__init__.py new file mode 100644 index 0000000..e7d34d8 --- /dev/null +++ b/ooldtp/__init__.py @@ -0,0 +1,4 @@ +from _context import Context + +def context(window_name): + return Context(window_name) diff --git a/ooldtp/_context.py b/ooldtp/_context.py new file mode 100644 index 0000000..3f8cbbf --- /dev/null +++ b/ooldtp/_context.py @@ -0,0 +1,17 @@ +import ldtp + +class Context: + def __init__(self, window_name): + self._window_name = window_name + def __getattr__(self, name): + obj = getattr(ldtp, name) + if callable(obj): + return _ContextFuncWrapper(self._window_name, obj) + raise AttributeError + +class _ContextFuncWrapper: + def __init__(self, window_name, func): + self._window_name = window_name + self._func = func + def __call__(self, *args, **kwargs): + return self._func(self._window_name, *args, **kwargs) |