[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4631] contrib/py/scripts/addons: initial commit
Alexander N
alpha-beta-release at gmx.net
Thu Jul 18 19:13:04 CEST 2013
Revision: 4631
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4631
Author: beta-tester
Date: 2013-07-18 17:13:04 +0000 (Thu, 18 Jul 2013)
Log Message:
-----------
initial commit
Added Paths:
-----------
contrib/py/scripts/addons/io_scene_fpx/
contrib/py/scripts/addons/io_scene_fpx/__init__.py
contrib/py/scripts/addons/io_scene_fpx/cfb_spec.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_strings.py
contrib/py/scripts/addons/io_scene_fpx/fpx_ui.py
contrib/py/scripts/addons/io_scene_fpx/fpx_utils.py
contrib/py/scripts/addons/io_scene_fpx/lzo_spec.py
Added: contrib/py/scripts/addons/io_scene_fpx/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/__init__.py (rev 0)
+++ contrib/py/scripts/addons/io_scene_fpx/__init__.py 2013-07-18 17:13:04 UTC (rev 4631)
@@ -0,0 +1,112 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+###############################################################################
+#234567890123456789012345678901234567890123456789012345678901234567890123456789
+#--------1---------2---------3---------4---------5---------6---------7---------
+
+
+# ##### BEGIN COPYRIGHT BLOCK #####
+#
+# initial script copyright (c)2013 Alexander Nussbaumer
+#
+# ##### END COPYRIGHT BLOCK #####
+
+
+bl_info = {
+ 'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
+ 'description': "Import Future Pinball Model, Library and Table files",
+ 'author': "Alexander Nussbaumer",
+ 'version': (0, 0, 0, '2013-07-18'),
+ 'blender': (2, 68, 0),
+ 'location': "File > Import",
+ 'warning': "",
+ 'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/"\
+ "Py/Scripts/Import-Export/FuturePinball_FPx",
+ 'tracker_url': "http://projects.blender.org/tracker/index.php"\
+ "?func=detail&aid=0",
+ 'category': "Import-Export",
+ }
+
+
+# To support reload properly, try to access a package var,
+# if it's there, reload everything
+if 'bpy' in locals():
+ import imp
+ if 'io_scene_fpx.fpx_ui' in locals():
+ imp.reload(io_scene_fpx.fpx_ui)
+else:
+ from io_scene_fpx.fpx_ui import (
+ FpmImportOperator,
+ FplImportOperator,
+ FptImportOperator,
+ )
+
+
+#import blender stuff
+from bpy.utils import (
+ register_module,
+ unregister_module,
+ )
+from bpy.types import (
+ INFO_MT_file_export,
+ INFO_MT_file_import,
+ )
+
+
+###############################################################################
+# registration
+def register():
+ ####################
+ # F8 - key
+ import imp
+ imp.reload(fpx_ui)
+ # F8 - key
+ ####################
+
+ fpx_ui.register()
+
+ register_module(__name__)
+ INFO_MT_file_import.append(FpmImportOperator.menu_func)
+ INFO_MT_file_import.append(FplImportOperator.menu_func)
+ INFO_MT_file_import.append(FptImportOperator.menu_func)
+
+
+def unregister():
+ fpx_ui.unregister()
+
+ unregister_module(__name__)
+ INFO_MT_file_import.remove(FpmImportOperator.menu_func)
+ INFO_MT_file_import.remove(FplImportOperator.menu_func)
+ INFO_MT_file_import.remove(FptImportOperator.menu_func)
+
+
+###############################################################################
+# global entry point
+if (__name__ == "__main__"):
+ register()
+
+###############################################################################
+
+
+###############################################################################
+#234567890123456789012345678901234567890123456789012345678901234567890123456789
+#--------1---------2---------3---------4---------5---------6---------7---------
+# ##### END OF FILE #####
Added: contrib/py/scripts/addons/io_scene_fpx/cfb_spec.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/cfb_spec.py (rev 0)
+++ contrib/py/scripts/addons/io_scene_fpx/cfb_spec.py 2013-07-18 17:13:04 UTC (rev 4631)
@@ -0,0 +1,840 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+###############################################################################
+#234567890123456789012345678901234567890123456789012345678901234567890123456789
+#--------1---------2---------3---------4---------5---------6---------7---------
+
+
+# ##### BEGIN COPYRIGHT BLOCK #####
+#
+# initial script copyright (c)2013 Alexander Nussbaumer
+#
+# ##### END COPYRIGHT BLOCK #####
+
+## this is a basic, partial and stripped implementation to read
+## [MS-CFB]: Compound File Binary File Format
+## http://msdn.microsoft.com/en-us/library/dd942138.aspx
+
+
+from struct import (
+ unpack,
+ )
+from io import (
+ SEEK_SET,
+ SEEK_CUR,
+ SEEK_END,
+ )
+from time import (
+ strftime,
+ gmtime,
+ )
+from operator import (
+ attrgetter,
+ )
+
+
+class DEBUG_CFB_SPEC:
+ errors = []
+ warnings = []
+ enabled = True
+ fire_exception = False
+
+ @staticmethod
+ def unknown_value(value):
+ if DEBUG.enabled:
+ s = "#DEBUG {} ???".format(value)
+ if DEBUG.fire_exception:
+ raise ValueError(s)
+ return s
+ pass
+
+ @staticmethod
+ def add_error(value):
+ DEBUG_CFB_SPEC.errors.append(value)
+
+ @staticmethod
+ def add_warning(value):
+ DEBUG_CFB_SPEC.warnings.append(value)
+
+
+###############################################################################
+#234567890123456789012345678901234567890123456789012345678901234567890123456789
+#--------1---------2---------3---------4---------5---------6---------7---------
+class Cfb_RawIO_Reader:
+ SEPARATOR = '\\'
+
+ __slots__ = (
+ '__raw_io',
+ '__compound_file_header'
+ )
+
+ def __init__(self, raw_io):
+ self.__raw_io = raw_io
+ self.__compound_file_header = Cfb_File_Header(self)
+ self.__compound_file_header.read()
+
+ def tell(self):
+ self.__raw_io.tell()
+
+ def seek(self, offset, whence=SEEK_SET):
+ return self.__raw_io.seek(offset, whence)
+
+ def read(self, n=-1):
+ """ read raw byte(s) buffer """
+ return self.__raw_io.read(n)
+
+ def get_stream_directory_names(self):
+ return self.__compound_file_header.get_stream_directory_names()
+
+ def get_stream_directory_entry(self, path_name):
+ return self.__compound_file_header.get_stream_directory_entry()
+
+ def get_stream(self, path_name):
+ directory_entry = self.__compound_file_header.get_stream_directory_entry(path_name)
+ if directory_entry and not directory_entry.is_directory():
+ stream_sector_list = self.__compound_file_header.get_stream_sector_list(directory_entry)
+ if self.__compound_file_header.is_large_stream(directory_entry.Stream_Size):
+ sector_shift = self.__compound_file_header.Sector_Shift
+ else:
+ sector_shift = self.__compound_file_header.Mini_Sector_Shift
+ return Cfb_Stream_Reader(
+ self,
+ stream_sector_list,
+ sector_shift,
+ path_name,
+ directory_entry
+ )
+ return None
+
+ def read_byte(self):
+ """ read a single byte value """
+ return unpack('<B', self.__raw_io.read(Cfb_Size_Type.BYTE))[0]
+
+ def read_word(self):
+ """ read a single word value """
+ return unpack('<H', self.__raw_io.read(Cfb_Size_Type.WORD))[0]
+
+ def read_dword(self):
+ """ read a single double word value """
+ return unpack('<I', self.__raw_io.read(Cfb_Size_Type.DWORD))[0]
+
+ def read_qword(self):
+ """ read a single quad word value """
+ return unpack('<Q', self.__raw_io.read(Cfb_Size_Type.QWORD))[0]
+
+ CLSID_NULL = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+ #CLSID_NULL = (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, )
+ def read_clsid(self):
+ """
+ b'\xf0\xf1\xf2\xf3\xe0\xe1\xd0\xd1\x07\x06\x05\x04\x03\x02\x01\x00'
+ '<L2H8B'
+ (0xF3F2F1F0, 0xE1E0, 0xD1D0, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, )
+ """
+ #return unpack('<L2H8B', self.__raw_io.read(Cfb_Size_Type.CLSID))
+ return self.__raw_io.read(Cfb_Size_Type.CLSID)
+
+
+###############################################################################
+#234567890123456789012345678901234567890123456789012345678901234567890123456789
+#--------1---------2---------3---------4---------5---------6---------7---------
+class Cfb_Stream_Reader:
+ """
+ for internal use only
+ do not create an instance directly
+ """
+ __slots__ = (
+ '__compound_raw_io',
+ '__directory_entry',
+ '__path_name',
+ '__stream_sector_list',
+ '__stream_sector_shift',
+ '__stream_sector_size',
+ '__stream_sector_mask',
+ '__stream_sector_index',
+ '__stream_sector_position',
+ '__stream_position',
+ )
+
+ def __init__(self, compound_raw_io, sector_list, sector_shift, path_name, directory_entry):
+ if not isinstance(compound_raw_io, Cfb_RawIO_Reader):
+ raise TypeError("Cfb_Stream_Reader(compound_raw_io)")
+ if not isinstance(directory_entry, Cfb_File_Directory_Entry):
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list