[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [524] tags/2_49_bundle/py/scripts/ bpymodules/pyffi: Update PyFFI from 2.0.4 to 2.1.4.
Amorilia
amorilia.gamebox at gmail.com
Sun Mar 28 13:16:20 CEST 2010
Revision: 524
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=524
Author: amorilia
Date: 2010-03-28 13:16:20 +0200 (Sun, 28 Mar 2010)
Log Message:
-----------
Update PyFFI from 2.0.4 to 2.1.4.
Here's a log of all changes (copied from PyFFI's CHANGELOG.txt):
Release 2.1.4 (19 Mar 2010)
===========================
* Extra names in oblivion_optimize.ini skip list for known mods
(contributed by Tommy_H).
* New spells
- modify_collisiontomopp
- opt_reducegeometry
- opt_packcollision
* Windows right-click optimize method now uses default.ini and
oblivion_optimize.ini.
* fix_texturepath now fixes paths that include the whole drive path
to just the textures/... path.
* The optimize spell has been fixed to update Fallout 3 style tangent
space (fixes issue #2941568, reported by xjdhdr).
Release 2.1.3 (20 Feb 2010)
===========================
* Added toaster option to process files in archives (not yet functional).
* Added toaster option to resume, by skipping existing files in the
destination folder.
* Toaster now removes incompletely written files on CTRL-C (to avoid
corrupted files).
* Fixed makefarnif spell (now no longer deletes vertex colors).
* New spells
- fix_delunusedroots
- modify_bonepriorities
- modify_interpolatortransrotscale
- modify_delinterpolatortransformdata
- opt_delunusedbones
* The niftoaster optimize spell now also includes fix_delunusedroots.
* Removed unused pep8 attribute conversion code.
* Toasters can now be configured from an ini file.
* bhkMalleableHinge update_a_b bugfix (reported by Ghostwalker71).
Release 2.1.2 (Jan 16, 2010)
============================
* Fallout 3 skin partition flag bugfix (reported by Ghostwalker71).
* Fixed bug in optimize spell, when has_vertex_colors was False but vertex
color array was present (reported by Baphometal, debugged by
PacificMorrowind).
* Initial bsa file support (Morrowind, Oblivion, and Fallout 3).
Release 2.1.1 (Jan 11, 2010)
============================
* Accidently released corrupted nif.xml (affected Fallout 3), so this is just
a quick bugfix release including the correct nif.xml.
Release 2.1.0 (Jan 10, 2010)
============================
* Improved windows installer.
* Compatibility fix for Python 2.5 users (reported by mac1415).
* Renamed some internal modules for pep8 compliance.
* All classes and attributes are now in pep8 style. For compatibility,
camelCase attributes are generated too (however this will be dropped for
py3k).
* Renamed a few niftoaster spells.
- fix_strip -> modify_delbranches
- fix_disableparallax -> modify_disableparallax
* New niftoaster spells.
- fix_cleanstringpalette: removes unused strings from string palette.
- modify_substitutestringpalette: regular expression substitution of
strings in a string palette.
- modify_scaleanimationtime: numeric scaling of animations.
- modify_reverseanimation: reverses an animation (ie useful for making
only an open animation and then running this to get a close animation).
- modify_collisionmaterial: sets any collision materials in a nif to
specified type.
- modify_delskinshapes: Delete any geometries with a material name of
'skin'
- modify_texturepathlowres: Changes the texture path by replacing
'textures/*' with 'textures/lowres/*'. used mainly for making _far.nifs.
- modify_addstencilprop: Adds a NiStencilProperty to each geometry if it is
not present.
- modify_substitutetexturepath: regular expression substitution of
a texture path.
- modify_makeskinlessnif: Spell to make fleshless CMR (Custom Model Races)
clothing/armour type nifs. (runs modify_delskinshapes and modify_addstencilprop)
- modify_makefarnif: Spell to make _far type nifs.
* Bugfix for niftoaster dump spell.
* New --suffix option for toaster (similar to the already existing --prefix
option).
* New --skip and --only toaster options to toast files by regular expression.
* New --jobs toaster option which enables multithreaded toasting.
* New --source-dir and --dest-dir options to save toasted nifs in a given
destination folder.
* Added workaround for memory leaks (at the moment requires --jobs >= 2 to be
functional).
* The niftoaster opt_geometry spell now always skips nif files when a
similarly named tri or egm file is found.
* Added support for Atlantica nifs.
* Added support for Joymaster Interactive Howling Sword nifs.
Release 2.0.5 (Nov 23, 2009)
============================
* Added regression test and fixed rare bug in stripification (reported by
PacificMorrowind, see issue #2889048).
* Improved strip stitching algorithm: *much* more efficient, and
now rarely needs more than 2 stitches per strip.
* Improved stripifier algorithm: runs about 30% faster, and usually
yields slightly better strips.
* Added new modify_texturepath and modify_collisiontype niftoaster spells
(contributed by PacificMorrowind).
* Various fixes and improvements for 20.5.0.0+ nifs.
* Check endian type when processing nifs.
* Source release now includes missing egm.xml and tri.xml files (reported
by skomut, fixes issue #2902125).
Modified Paths:
--------------
tags/2_49_bundle/py/scripts/bpymodules/pyffi/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/dds/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/nif/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/check.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/check.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/dump.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/fix.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/optimize.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/graph.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/inertia.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/mathutils.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/mopp.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/trianglemesh.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/trianglestripifier.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/tristrip.py
Added Paths:
-----------
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/bsa.xml
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/egm/
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/egm/__init__.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/egm/egm.xml
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/nif/nifxml/
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/nif/nifxml/nif.xml
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/any_type.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/array_type.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/binary_type.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/common.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/editable.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/simple_type.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/array.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/basic.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/bit_struct.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/enum.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/expression.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/struct_.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/spells/nif/modify.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/utils/vertex_cache.py
Removed Paths:
-------------
tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/nif/nif.xml
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/AnyType.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/ArrayType.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/BinaryType.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/Common.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/Editable.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/SimpleType.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/Array.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/Basic.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/BitStruct.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/Enum.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/Expression.py
tags/2_49_bundle/py/scripts/bpymodules/pyffi/object_models/xml/Struct.py
Modified: tags/2_49_bundle/py/scripts/bpymodules/pyffi/__init__.py
===================================================================
--- tags/2_49_bundle/py/scripts/bpymodules/pyffi/__init__.py 2010-03-27 14:51:44 UTC (rev 523)
+++ tags/2_49_bundle/py/scripts/bpymodules/pyffi/__init__.py 2010-03-28 11:16:20 UTC (rev 524)
@@ -4,7 +4,7 @@
.. toctree::
:maxdepth: 3
-
+
pyffi.formats
pyffi.spells
pyffi.object_models
@@ -48,8 +48,7 @@
#
# ***** END LICENSE BLOCK *****
-__version__ = '2.0.4'
+__version__ = '2.1.4'
__hexversion__ = eval('0x%02X%02X%02X'
% tuple(int(x) for x in __version__.split('.')))
-
Modified: tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/__init__.py
===================================================================
--- tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/__init__.py 2010-03-27 14:51:44 UTC (rev 523)
+++ tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/__init__.py 2010-03-28 11:16:20 UTC (rev 524)
@@ -16,13 +16,17 @@
.. toctree::
:maxdepth: 2
-
+
+ pyffi.formats.bsa
pyffi.formats.cgf
pyffi.formats.dae
pyffi.formats.dds
+ pyffi.formats.egm
+ pyffi.formats.esp
pyffi.formats.kfm
pyffi.formats.nif
pyffi.formats.tga
+ pyffi.formats.tri
Adding new formats
------------------
@@ -35,10 +39,10 @@
Note that the files which make up the following example can all be found in
the examples/simple directory of the source distribution of pyffi.
-Suppose you have a simple file format, which consists of an integer, followed
-by a list of integers as many as described by the first integer. We start
-by creating an XML file, call it :file:`simple.xml`, which describes this format
-in a way that pyffi can understand:
+Suppose you have a simple file format, which consists of an integer,
+followed by a list of integers as many as described by the first
+integer. We start by creating an XML file, call it :file:`simple.xml`,
+which describes this format in a way that pyffi can understand:
.. literalinclude:: ../examples/simple/simple.xml
:language: xml
@@ -56,10 +60,10 @@
base class triggers the transformation of xml into Python classes;
how these classes can be used will be explained further.
- - The :attr:`~pyffi.object_models.xml.FileFormat.xmlFileName`
+ - The :attr:`~pyffi.object_models.xml.FileFormat.xml_file_name`
class attribute provides the name of the xml file that describes
the structures we wish to generate. The
- :attr:`~pyffi.object_models.xml.FileFormat.xmlFilePath`
+ :attr:`~pyffi.object_models.xml.FileFormat.xml_file_path`
attribute gives a list of locations of where to look for this
file; in our case we have simply chosen to put :file:`simple.xml`
in the same directory as :file:`simple.py`.
@@ -69,10 +73,10 @@
addition to the attributes :attr:`numIntegers` and
:attr:`integers` which have been created from the XML.
- - Finally, the :mod:`pyffi.object_models.Common` module implements
+ - Finally, the :mod:`pyffi.object_models.common` module implements
the most common basic types, such as integers, characters, and
floats. In the above example we have taken advantage of
- :class:`pyffi.object_models.Common.Int`, which defines a signed
+ :class:`pyffi.object_models.common.Int`, which defines a signed
32-bit integer, exactly the type we need.
Reading and Writing Files
Added: tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/__init__.py
===================================================================
--- tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/__init__.py (rev 0)
+++ tags/2_49_bundle/py/scripts/bpymodules/pyffi/formats/bsa/__init__.py 2010-03-28 11:16:20 UTC (rev 524)
@@ -0,0 +1,320 @@
+"""
+:mod:`pyffi.formats.bsa` --- Bethesda Archive (.bsa)
+====================================================
+
+.. warning::
+
+ This module is still a work in progress,
+ and is not yet ready for production use.
+
+A .bsa file is an archive format used by Bethesda (Morrowind, Oblivion,
+Fallout 3).
+
+Implementation
+--------------
+
+.. autoclass:: BsaFormat
+ :show-inheritance:
+ :members:
+
+Regression tests
+----------------
+
+Read a BSA file
+^^^^^^^^^^^^^^^
+
+>>> # check and read bsa file
+>>> stream = open('tests/bsa/test.bsa', 'rb')
+>>> data = BsaFormat.Data()
+>>> data.inspect_quick(stream)
+>>> data.version
+103
+>>> data.inspect(stream)
+>>> data.folders_offset
+36
+>>> hex(data.archive_flags.to_int())
+'0x703'
+>>> data.num_folders
+1
+>>> data.num_files
+7
+>>> #data.read(stream)
+>>> # TODO check something else...
+
+Parse all BSA files in a directory tree
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+>>> for stream, data in BsaFormat.walkData('tests/bsa'):
+... print(stream.name)
+tests/bsa/test.bsa
+
+Create an BSA file from scratch and write to file
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+>>> data = BsaFormat.Data()
+>>> # TODO store something...
+>>> from tempfile import TemporaryFile
+>>> stream = TemporaryFile()
+>>> #data.write(stream)
+"""
+
+# ***** BEGIN LICENSE BLOCK *****
+#
+# Copyright (c) 2007-2009, Python File Format Interface
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+#
+# * Neither the name of the Python File Format Interface
+# project nor the names of its contributors may be used to endorse
+# or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# ***** END LICENSE BLOCK *****
+
+from itertools import izip
+import logging
+import struct
+import os
+import re
+
+import pyffi.object_models.xml
+import pyffi.object_models.common
+from pyffi.object_models.xml.basic import BasicBase
+import pyffi.object_models
+from pyffi.utils.graph import EdgeFilter
+
+
+class BsaFormat(pyffi.object_models.xml.FileFormat):
+ """This class implements the BSA format."""
+ xml_file_name = 'bsa.xml'
+ # where to look for bsa.xml and in what order:
+ # BSAXMLPATH env var, or BsaFormat module directory
+ xml_file_path = [os.getenv('BSAXMLPATH'), os.path.dirname(__file__)]
+ # file name regular expression match
+ RE_FILENAME = re.compile(r'^.*\.bsa$', re.IGNORECASE)
+
+ # basic types
+ UInt32 = pyffi.object_models.common.UInt
+ ZString = pyffi.object_models.common.ZString
+
+ # implementation of bsa-specific basic types
+
+ class Hash(pyffi.object_models.common.UInt64):
+
+ def __str__(self):
+ return "0x%016X" % self._value
+
+ def get_detail_display(self):
+ return self.__str__()
+
+ class BZString(pyffi.object_models.common.SizedString):
+
+ def get_size(self, **kwargs):
+ return 2 + len(self._value)
+
+ def read(self, stream, data=None):
+ length, = struct.unpack('<B', stream.read(1))
+ self._value = stream.read(length)[:-1] # strip trailing null byte
+
+ def write(self, stream, data=None):
+ stream.write(struct.pack('<B', len(self._value)))
+ stream.write(self._value)
+ stream.write(struct.pack('<B', 0))
+
+ class FileVersion(pyffi.object_models.common.UInt):
+ """Basic type which implements the header of a BSA file."""
+
+ def __init__(self, **kwargs):
+ BasicBase.__init__(self, **kwargs)
+
+ def read(self, stream, **kwargs):
+ """Read header string from stream and check it.
+
+ :param stream: The stream to read from.
+ :type stream: file
+ """
+ hdrstr = stream.read(4)
+ # check if the string is correct
+ if hdrstr == "\x00\x01\x00\x00".encode("ascii"):
+ # morrowind style, set version too!
+ self._value = 0
+ elif hdrstr == "BSA\x00".encode("ascii"):
+ # oblivion an up: read version
+ self._value, = struct.unpack("<I", stream.read(4))
+ else:
+ raise ValueError(
+ "invalid BSA header:"
+ " expected '\\x00\\x01\\x00\\x00' or 'BSA\\x00'"
+ " but got '%s'" % hdrstr)
+
+ def write(self, stream, **kwargs):
+ """Write the header string to stream.
+
+ :param stream: The stream to write to.
+ :type stream: file
+ """
+ if self._value >= 103:
+ stream.write("BSA\x00".encode("ascii"))
+ stream.write(struct.pack("<I", self._value))
+ else:
+ stream.write("\x00\x01\x00\x00".encode("ascii"))
+
+ def get_size(self, **kwargs):
+ """Return number of bytes the header string occupies in a file.
+
+ :return: Number of bytes.
+ """
+ return 4
+
+ @staticmethod
+ def version_number(version_str):
+ """Converts version string into an integer.
+
+ :param version_str: The version string.
+ :type version_str: str
+ :return: A version integer.
+
+ >>> BsaFormat.version_number('103')
+ 103
+ >>> BsaFormat.version_number('XXX')
+ -1
+ """
+ try:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list