[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4741] contrib/py/scripts/addons/ io_scene_fpx: fixed filepath handling for Linux

Alexander N. alpha-beta-release at gmx.net
Thu Sep 5 19:37:51 CEST 2013


Revision: 4741
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4741
Author:   beta-tester
Date:     2013-09-05 17:37:51 +0000 (Thu, 05 Sep 2013)
Log Message:
-----------
fixed filepath handling for Linux

- added toGoodFilePath, to conversion from Windows to Linux (MacOS?)

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_fpx/__init__.py
    contrib/py/scripts/addons/io_scene_fpx/fpx_import.py
    contrib/py/scripts/addons/io_scene_fpx/fpx_resource.blend
    contrib/py/scripts/addons/io_scene_fpx/fpx_spec.py
    contrib/py/scripts/addons/io_scene_fpx/fpx_utils.py

Modified: contrib/py/scripts/addons/io_scene_fpx/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/__init__.py	2013-09-04 22:59:25 UTC (rev 4740)
+++ contrib/py/scripts/addons/io_scene_fpx/__init__.py	2013-09-05 17:37:51 UTC (rev 4741)
@@ -34,7 +34,7 @@
     'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
     'description': "Import Future Pinball Model, Library and Table files",
     'author': "Alexander Nussbaumer",
-    'version': (0, 0, 309032),
+    'version': (0, 0, 309051),
     'blender': (2, 68, 0),
     'location': "File > Import",
     'warning': "",
@@ -53,8 +53,10 @@
 #       models got multiple materials assigned.
 #       models got christal material assigned instead texture.
 # - issue: some images could not be loaded to blender.
-#       IMB_ibImageFromMemory: unknown fileformat (e.g.:__grab__fpl__\bulb_trigger_star_v2\Bulb-Trigger-Star-v2.bmp)
-#       TGS x% missing?
+#       #DEBUG fpl images.load C:\Users\user\AppData\Local\Temp\__grab__fpl__\bulb_trigger_star_v2\Bulb-Trigger-Star-v2.bmp
+#       IMB_ibImageFromMemory: unknown fileformat (C:\Users\user\AppData\Local\Temp\__grab__fpl__\bulb_trigger_star_v2\Bulb-Trigger-Star-v2.bmp)
+#       #DEBUG fpl images.load C:\Users\user\AppData\Local\Temp\__grab__fpl__\gameover\GameOver.tga
+#       decodetarga: incomplete file, 7.9% missing
 #
 # - todo: delete all unused temporary scenes with its content.
 #       to shrink file size.

Modified: contrib/py/scripts/addons/io_scene_fpx/fpx_import.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/fpx_import.py	2013-09-04 22:59:25 UTC (rev 4740)
+++ contrib/py/scripts/addons/io_scene_fpx/fpx_import.py	2013-09-05 17:37:51 UTC (rev 4741)
@@ -488,13 +488,19 @@
                                     rename_active_fpm(self.__context, FORMAT_RESOURCE.format(file_name, key_name))
 
                             elif type == Fpl_Library_Type.TYPE_GRAPHIC:
-                                #print("#DEBUG", type, key_name)
+                                #print("#DEBUG fpl images.load", item_path)
+                                #print("#DEBUG", type, key_name, item_path)
                                 blend_image = self.__data.images.load(item_path)
-                                blend_image.name = FpxUtilities.toGoodName(FORMAT_RESOURCE.format(file_name, FORMAT_IMAGE.format(key_name)))
-                                blend_image.pack()
-                                blend_image.use_fake_user = True
-                                item_dir, item_file = path.split(item_path)
-                                blend_image.filepath_raw = "//unpacked_resource/{}".format(item_file)
+                                if blend_image:
+                                    blend_image.name = FpxUtilities.toGoodName(FORMAT_RESOURCE.format(file_name, FORMAT_IMAGE.format(key_name)))
+                                    if blend_image.has_data:
+                                        blend_image.update()
+                                    blend_image.pack()
+                                    blend_image.use_fake_user = True
+                                    item_dir, item_file = path.split(item_path)
+                                    blend_image.filepath_raw = "//unpacked_resource/{}".format(item_file)
+                                if not blend_image or not blend_image.has_data:
+                                    print("#DEBUG fpl images.load failed", item_path)
 
                         else:
                             pass
@@ -2714,6 +2720,7 @@
         #print("#DEBUG LoadFromPathLibrary", name, type, lib, folder)
 
         filepath = path.join(folder, lib)
+        filepath = FpxUtilities.toGoodFilePath(filepath)
         if path.exists(filepath):
             FplImporter(
                     report=self.report,
@@ -2759,8 +2766,9 @@
             if fpx_item.get_value("linked"):
                 #print("#DEBUG GetLinked linked > ", type, fpx_item_name)
 
-                linked_path = fpx_item.get_value("linked_path").lower()
-                library_file, file_name = linked_path.split(Fpt_File_Reader.SEPARATOR)
+                win_linked_path = fpx_item.get_value("linked_path").lower()
+                linked_path = FpxUtilities.toGoodFilePath(win_linked_path)
+                library_file, file_name = linked_path.split(path.sep) #Fpt_File_Reader.SEPARATOR)
                 ## "Sci-Fi Classic GFX.fpl"
                 ## library_file = FpxUtilities.toGoodName(library_file)
                 ## file_name = FpxUtilities.toGoodName(file_name)
@@ -2789,12 +2797,18 @@
                 if item_type == Fpt_PackedLibrary_Type.TYPE_IMAGE:
                     item_path = dst_sub_path_names.get(fpx_item_name)
                     if item_path:
+                        #print("#DEBUG fpt images.load", item_path)
                         blend_image = self.__data.images.load(item_path)
-                        blend_image.name = blender_resource_name
-                        blend_image.pack()
-                        #blend_image.use_fake_user = True
-                        item_dir, item_file = path.split(item_path)
-                        blend_image.filepath_raw = "//unpacked_resource/{}".format(item_file)
+                        if blend_image:
+                            blend_image.name = blender_resource_name
+                            if blend_image.has_data:
+                                blend_image.update()
+                            blend_image.pack()
+                            #blend_image.use_fake_user = True
+                            item_dir, item_file = path.split(item_path)
+                            blend_image.filepath_raw = "//unpacked_resource/{}".format(item_file)
+                        if not blend_image or not blend_image.has_data:
+                            print("#DEBUG fpt images.load failed", item_path)
                 elif item_type == Fpt_PackedLibrary_Type.TYPE_MODEL:
                     item_data = dst_sub_path_names.get("data_{}".format(fpx_item_name))
                     if item_data:
@@ -3036,7 +3050,7 @@
             texture_slot.texture = None
         material_slot.material = None
 
-    if ops.object.material_slot_remove.poll:
+    if ops.object.material_slot_remove.poll():
         ops.object.material_slot_remove()
 
     for material in used_materials:

Modified: contrib/py/scripts/addons/io_scene_fpx/fpx_resource.blend
===================================================================
(Binary files differ)

Modified: contrib/py/scripts/addons/io_scene_fpx/fpx_spec.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/fpx_spec.py	2013-09-04 22:59:25 UTC (rev 4740)
+++ contrib/py/scripts/addons/io_scene_fpx/fpx_spec.py	2013-09-05 17:37:51 UTC (rev 4741)
@@ -2825,6 +2825,7 @@
             if item_name:
                 dst_sub_path = path.join(dst_path, item_name)
                 makedirs(dst_sub_path, mode=0o777, exist_ok=True)
+                #print("#DEBUG", item_name, dst_path, dst_sub_path)
                 dst_sub_path_names["sub_dir"] = dst_sub_path
             else:
                 dst_sub_path = dst_path
@@ -2835,7 +2836,8 @@
             dst_sub_path_names["type"] = item_type
 
             # grab preview
-            item_path = reader.get_value("preview_path")
+            win_item_path = reader.get_value("preview_path")
+            item_path = FpxUtilities.toGoodFilePath(win_item_path)
             item_data_len = reader.get_value("preview_data_len")
             item_data = reader.get_value("preview_data")
             if item_path and item_data:
@@ -2844,7 +2846,8 @@
                 dst_sub_path_names["preview_data"] = full_path
 
             # grab primary_model
-            item_path = reader.get_value("primary_model_path")
+            win_item_path = reader.get_value("primary_model_path")
+            item_path = FpxUtilities.toGoodFilePath(win_item_path)
             item_data_len = reader.get_value("primary_model_data_len")
             item_data = reader.get_value("primary_model_data")
             if item_path and item_data:
@@ -2853,7 +2856,8 @@
                 dst_sub_path_names["primary_model_data"] = full_path
 
             # grab secondary_model
-            item_path = reader.get_value("secondary_model_path")
+            win_item_path = reader.get_value("secondary_model_path")
+            item_path = FpxUtilities.toGoodFilePath(win_item_path)
             item_data_len = reader.get_value("secondary_model_data_len")
             item_data = reader.get_value("secondary_model_data")
             if item_path and item_data:
@@ -2862,7 +2866,8 @@
                 dst_sub_path_names["secondary_model_data"] = full_path
 
             # grab mask_model
-            item_path = reader.get_value("mask_model_path")
+            win_item_path = reader.get_value("mask_model_path")
+            item_path = FpxUtilities.toGoodFilePath(win_item_path)
             item_data_len = reader.get_value("mask_model_data_len")
             item_data = reader.get_value("mask_model_data")
             if item_path and item_data:
@@ -2871,7 +2876,8 @@
                 dst_sub_path_names["mask_model_data"] = full_path
 
             # grab reflection_model
-            item_path = reader.get_value("reflection_model_path")
+            win_item_path = reader.get_value("reflection_model_path")
+            item_path = FpxUtilities.toGoodFilePath(win_item_path)
             item_data_len = reader.get_value("reflection_model_data_len")
             item_data = reader.get_value("reflection_model_data")
             if item_path and item_data:
@@ -2976,7 +2982,9 @@
             dst_sub_path_names["type_{}".format(item_name)] = value._FTYP
 
             # grab item
-            item_path=path.split(value.FPAT)[1]
+            win_file_path = value.FPAT
+            file_path = FpxUtilities.toGoodFilePath(win_file_path)
+            item_path=path.split(file_path)[1]
             item_data=value.FDAT
             if item_path and item_data:
                 full_path = path.normpath(path.join(dst_sub_path, item_path))

Modified: contrib/py/scripts/addons/io_scene_fpx/fpx_utils.py
===================================================================

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list