pyffi.formats.dae
— COLLADA (.dae)¶
Warning
This module is not yet fully implemented, and is certainly not yet useful in its current state.
Implementation¶
-
class
pyffi.formats.dae.
DaeFormat
¶ Bases:
pyffi.object_models.xsd.FileFormat
This class implements the DAE format.
-
class
Data
(version=17039616)¶ Bases:
pyffi.object_models.Data
A class to contain the actual collada data.
-
getVersion
()¶ Get the collada version, as integer (for instance, 1.4.1 would be 0x01040100).
Returns: The version, as integer.
-
inspect
(stream)¶ Quickly checks whether the stream appears to contain collada data. Resets stream to original position. If the stream turns out to be collada, L{getVersion} is guaranteed to return the version.
Call this function if you simply wish to check that a file is a collada file without having to parse it completely.
Parameters: stream (file) – The file to inspect. Returns: True
if stream is collada,False
otherwise.
-
read
(stream)¶ Read collada data from stream.
Parameters: stream (file) – The file to read from.
-
write
(stream)¶ Write collada data to stream.
Parameters: stream (file) – The file to write to.
-
-
class
Regression tests¶
Create a DAE file¶
>>> daedata = DaeFormat.Data()
>>> print(daedata.collada)
<pyffi.formats.dae.Collada object at ...>
Read a DAE file¶
>>> # check and read dae file
>>> stream = open('tests/dae/cube.dae', 'rb')
>>> daedata = DaeFormat.Data()
>>> daedata.read(stream)
Traceback (most recent call last):
...
NotImplementedError
>>> # get DAE file root element
>>> #print(daedata.getRootElement())
>>> stream.close()
Parse all DAE files in a directory tree¶
>>> for stream, data in DaeFormat.walkData('tests/dae'):
... try:
... # the replace call makes the doctest also pass on windows
... print("reading %s" % stream.name.replace("\\", "/"))
... data.read(stream)
... except Exception:
... print("Warning: read failed due corrupt file, corrupt format description, or bug.")
reading tests/dae/cube.dae
Warning: read failed due corrupt file, corrupt format description, or bug.
Create a DAE file from scratch and write to file¶
>>> daedata = DaeFormat.Data()
>>> from tempfile import TemporaryFile
>>> stream = TemporaryFile()
>>> daedata.write(stream)
Traceback (most recent call last):
...
NotImplementedError