[gedit-latex] utils: Remove unused @require decorator.



commit 72ce3e8742443ce22f05f82e4b0324c8179468be
Author: Josà Aliste <jaliste src gnome org>
Date:   Thu Feb 2 08:31:09 2012 +0100

    utils: Remove unused @require decorator.

 latex/completion.py |    3 ++-
 latex/util.py       |   49 -------------------------------------------------
 2 files changed, 2 insertions(+), 50 deletions(-)
---
diff --git a/latex/completion.py b/latex/completion.py
index 5667d0c..c68b8b4 100644
--- a/latex/completion.py
+++ b/latex/completion.py
@@ -23,7 +23,8 @@ base.completion
 """
 
 from logging import getLogger
-from gi.repository import GObject, Gtk, Gdk, GdkPixbuf
+from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, GtkSource, Gedit
+
 
 from .preferences import Preferences
 
diff --git a/latex/util.py b/latex/util.py
index d6b572f..058a320 100644
--- a/latex/util.py
+++ b/latex/util.py
@@ -41,55 +41,6 @@ def singleton(cls):
         return instances[cls]
     return getinstance
 
-def require(arg_name, *allowed_types):
-    """
-    Type-checking decorator (see http://code.activestate.com/recipes/454322/)
-
-    Usage:
-
-    @require("x", int, float)
-    @require("y", float)
-    def foo(x, y):
-        return x+y
-
-    print foo(1, 2.5)          # Prints 3.5.
-    print foo(2.0, 2.5)        # Prints 4.5.
-    print foo("asdf", 2.5)     # Raises TypeError exception.
-    print foo(1, 2)            # Raises TypeError exception.
-    """
-    def make_wrapper(f):
-        if hasattr(f, "wrapped_args"):
-            wrapped_args = getattr(f, "wrapped_args")
-        else:
-            code = f.func_code
-            wrapped_args = list(code.co_varnames[:code.co_argcount])
-
-        try:
-            arg_index = wrapped_args.index(arg_name)
-        except ValueError:
-            raise NameError, arg_name
-
-        def wrapper(*args, **kwargs):
-            if len(args) > arg_index:
-                arg = args[arg_index]
-                if not isinstance(arg, allowed_types):
-                    type_list = " or ".join(str(allowed_type) for allowed_type in allowed_types)
-                    raise TypeError, "Expected '%s' to be %s; was %s." % (arg_name, type_list, type(arg))
-            else:
-                if arg_name in kwargs:
-                    arg = kwargs[arg_name]
-                    if not isinstance(arg, allowed_types):
-                        type_list = " or ".join(str(allowed_type) for allowed_type in allowed_types)
-                        raise TypeError, "Expected '%s' to be %s; was %s." % (arg_name, type_list, type(arg))
-
-            return f(*args, **kwargs)
-
-        wrapper.wrapped_args = wrapped_args
-        return wrapper
-
-    return make_wrapper
-
-
 from gi.repository import Gtk
 import traceback
 from xml.sax import saxutils



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]