Parcourir la source

Make current acl call catcher less verbose (don't print message when calling a methods starting with '__')

Yann Weber il y a 8 ans
Parent
révision
07570b6b8c
2 fichiers modifiés avec 6 ajouts et 17 suppressions
  1. 6
    5
      acl/acl.py
  2. 0
    12
      libs/transwrap/transwrap.py

+ 6
- 5
acl/acl.py Voir le fichier

@@ -53,9 +53,10 @@ class ACL(DefaultCallCatcher):
53 53
         if obj is method:
54 54
             print("\tCatched ! %s(%s %s)" % (obj.__name__, args, kwargs))
55 55
         else:
56
-            if hasattr(obj, '__name__'):
57
-                print("\tCatched ! %s.%s(%s %s)" % (obj.__name__, method.__name__, args,kwargs))
58
-            else:
59
-                print("\tCatched ! %s.%s(%s %s)" % (obj, method.__name__, args,kwargs))
60
-            print("\t\tCallobject = %s method = %s with %s %s" % (obj, method, args, kwargs))
56
+            if not method.__name__.startswith('__'):
57
+                if hasattr(obj, '__name__'):
58
+                    print("\tCatched ! %s.%s(%s %s)" % (obj.__name__, method.__name__, args,kwargs))
59
+                else:
60
+                    print("\tCatched ! %s.%s(%s %s)" % (obj, method.__name__, args,kwargs))
61
+                print("\t\tCallobject = %s method = %s with %s %s" % (obj, method, args, kwargs))
61 62
         return super().method_call(obj, method, args, kwargs)

+ 0
- 12
libs/transwrap/transwrap.py Voir le fichier

@@ -19,10 +19,6 @@ class DefaultCallCatcher(object):
19 19
     # @throw AttributeError if the attr does not exist
20 20
     @classmethod
21 21
     def attr_get(self, obj, attr_name):
22
-        if hasattr(obj, '__name__'):
23
-            print("\tCatched ! %s.%s"  % (obj.__name__, attr_name))
24
-        else:
25
-            print("\tCatched ! Get %s.%s"  % (obj, attr_name))
26 22
         return getattr(obj, attr_name)
27 23
     
28 24
     ## @brief Method designed to be called when a wrapped class method is called
@@ -34,14 +30,6 @@ class DefaultCallCatcher(object):
34 30
     # @return the call returned value
35 31
     @classmethod
36 32
     def method_call(cls, obj, method, args, kwargs):
37
-        if obj is method:
38
-            print("\tCatched ! %s(%s %s)" % (obj.__name__, args, kwargs))
39
-        else:
40
-            if hasattr(obj, '__name__'):
41
-                print("\tCatched ! %s.%s(%s %s)" % (obj.__name__, method.__name__, args,kwargs))
42
-            else:
43
-                print("\tCatched ! %s.%s(%s %s)" % (obj, method.__name__, args,kwargs))
44
-            print("\t\tCallobject = %s method = %s with %s %s" % (obj, method, args, kwargs))
45 33
         return cls.__do_call__(method, args, kwargs)
46 34
     
47 35
     ## @brief Do the method call

Loading…
Annuler
Enregistrer