[pygobject] Remove gi.overrides.overridefunc
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Remove gi.overrides.overridefunc
- Date: Mon, 27 Mar 2017 14:55:47 +0000 (UTC)
commit 275a92cb7fe530efe83349b3c7da557f22096fc0
Author: Christoph Reiter <creiter src gnome org>
Date: Tue Mar 21 19:19:33 2017 +0100
Remove gi.overrides.overridefunc
Move the code into override()
https://bugzilla.gnome.org/show_bug.cgi?id=686835
gi/overrides/__init__.py | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py
index 942e6ed..e262b6c 100644
--- a/gi/overrides/__init__.py
+++ b/gi/overrides/__init__.py
@@ -165,20 +165,6 @@ def load_overrides(introspection_module):
return proxy
-class overridefunc(object):
- """decorator for overriding a function"""
- def __init__(self, func):
- if not isinstance(func, CallableInfo):
- raise TypeError("func must be a gi function, got %s" % func)
-
- module_name = func.__module__.rsplit('.', 1)[-1]
- self.module = sys.modules["gi.repository." + module_name]
-
- def __call__(self, func):
- setattr(self.module, func.__name__, func)
- return func
-
-
def override(type_):
"""Decorator for registering an override.
@@ -187,8 +173,18 @@ def override(type_):
for example), so they have to be added to the module immediately.
"""
- if isinstance(type_, (types.FunctionType, CallableInfo)):
- return overridefunc(type_)
+ if isinstance(type_, CallableInfo):
+ func = type_
+ namespace = func.__module__.rsplit('.', 1)[-1]
+ module = sys.modules["gi.repository." + namespace]
+
+ def wrapper(func):
+ setattr(module, func.__name__, func)
+ return func
+
+ return wrapper
+ elif isinstance(type_, types.FunctionType):
+ raise TypeError("func must be a gi function, got %s" % type_)
else:
try:
info = getattr(type_, '__info__')
@@ -214,6 +210,10 @@ def override(type_):
return type_
+overridefunc = override
+"""Deprecated"""
+
+
def deprecated(fn, replacement):
"""Decorator for marking methods and classes as deprecated"""
@wraps(fn)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]