Commits

Henning Schröder committed 37e3de3

import from path

Comments (0)

Files changed (1)

pycode/stubgen.py

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import inspect
+import os
 import re
+import imp
 import textwrap
 from types import (
    ModuleType, ClassType, ObjectType, MethodType, FunctionType, UnboundMethodType,
 
     
     def __init__(self, module_name):
-        mod = __import__(module_name, {}, {}, [])
+        if "/" in module_name:
+            name_ext = os.path.basename(module_name)
+            name, suffix = os.path.splitext(name_ext)
+            mod = imp.load_module(name, open(module_name), module_name, (suffix, "rb", 3))
+            mod.__file__ = module_name
+            module_name = name
+        else:
+            #fh, filename, (suffix, mode, type_ = imp.find_module(mdule_name)
+            #mod = imp.load_module(module_name, fh, module_name, (suffix, mode, type_))
+            mod = __import__(module_name, {}, {}, [])
         for name in module_name.split(".")[1:]:
             mod = getattr(mod, name)
         try:
 
 def test_sc():
     #s = StubCreator("math")
-    s = StubCreator("PyQt4.QtGui")
+    #s = StubCreator("PyQt4.QtGui")
     #s = StubCreator("_socket")
+    s = StubCreator("/usr/lib64/python2.7/site-packages/sip.so")
     print s
 
     
 if __name__ == "__main__":        
-    test_sp()
+    #test_sp()
+    test_sc()
+