Pārlūkot izejas kodu

Enables more verbose messages for module overwriting

Yann Weber 8 gadus atpakaļ
vecāks
revīzija
0f6efd899a
1 mainītis faili ar 13 papildinājumiem un 4 dzēšanām
  1. 13
    4
      lodel/context.py

+ 13
- 4
lodel/context.py Parādīt failu

@@ -70,8 +70,6 @@ class LodelMetaPathFinder(importlib.abc.MetaPathFinder):
70 70
     
71 71
     def find_spec(fullname, path, target = None):
72 72
         if fullname.startswith(CTX_PKG):
73
-            #print("find_spec called : fullname=%s path=%s target=%s" % (
74
-            #    fullname, path, target))
75 73
             spl = fullname.split('.')
76 74
             site_identifier = spl[1]
77 75
             #creating a symlink to represent the lodel site package
@@ -332,6 +330,8 @@ initialize it anymore")
332 330
     #@note designed to implements warning messages or stuff like that
333 331
     #when doing nasty stuff
334 332
     #
333
+    #@warning Logging stuffs may lead in a performance issue
334
+    #
335 335
     #@todo try to use the logger module instead of warnings
336 336
     #@param globs globals : the globals where we want to expose our
337 337
     #module alias
@@ -340,8 +340,17 @@ initialize it anymore")
340 340
     @staticmethod
341 341
     def safe_exposure(globs, obj, alias):
342 342
         if alias in globs:
343
-            warnings.warn("A module exposure leads in globals overwriting for \
344
-key '%s'" % alias)
343
+            if globs[alias] != obj:
344
+                print("Context '%s' : A module exposure leads in globals overwriting for \
345
+key '%s' with a different value : %s != %s" % (LodelContext.get_name(), alias, globs[alias], obj))
346
+                """#Uncomment this bloc to display a stack trace for dangerous modules overwriting
347
+                print("DEBUG INFOS : ")
348
+                import traceback
349
+                traceback.print_stack()
350
+                """
351
+            else:
352
+                print("Context '%s' : A module exposure leads in a useless replacement for \
353
+key '%s'" % (LodelContext.get_name(),alias))
345 354
         globs[alias] = obj
346 355
         
347 356
     ##@brief Create a context from a path and returns the context name

Notiek ielāde…
Atcelt
Saglabāt