瀏覽代碼

intelligent library search

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@155 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
sebastianhempel 17 年之前
父節點
當前提交
0d5bb1c427
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      port/PyAssimp/pyassimp/helper.py

+ 11 - 2
port/PyAssimp/pyassimp/helper.py

@@ -7,6 +7,7 @@ Some fancy helper functions.
 import os
 import os
 import ctypes
 import ctypes
 import structs
 import structs
+import operator
 from errors import AssimpError
 from errors import AssimpError
 from ctypes import POINTER
 from ctypes import POINTER
 
 
@@ -29,6 +30,8 @@ def search_library():
     #this path
     #this path
     folder = os.path.dirname(__file__)
     folder = os.path.dirname(__file__)
     
     
+    candidates = []
+    
     #test every file
     #test every file
     for filename in os.listdir(folder):
     for filename in os.listdir(folder):
         library = os.path.join(folder, filename)
         library = os.path.join(folder, filename)
@@ -51,6 +54,12 @@ def search_library():
                 #Library found!
                 #Library found!
                 load.restype = POINTER(structs.SCENE)
                 load.restype = POINTER(structs.SCENE)
                 
                 
-                return (load, release)
+                candidates.append((library, load, release))
     
     
-    raise AssimpError, "assimp library not found"
+    if not candidates:
+        #no library found
+        raise AssimpError, "assimp library not found"
+    else:
+        #get the newest library
+        candidates = map(lambda x: (os.lstat(x[0])[-2], x), candidates)
+        return max(candidates, key=operator.itemgetter(0))[1][1:]