LettError / designSpaceDocument

Python reader and writer object for designspace files.
35 stars 9 forks source link

DesignSpaceProcessor.generateUFO() fails in Python 3 #17

Closed mashabow closed 7 years ago

mashabow commented 7 years ago

The designspace location is stored in lib.plist (see https://github.com/LettError/designSpaceDocument/commit/659a79fb8909986b459a95be6d420287bf8d340f), but in Python 3 dict.items() returns a dict_items object instead of a list, and this is not supported in plistlib.

Python 3.5.3 (default, Aug  7 2017, 17:02:41)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from designSpaceDocument.ufoProcessor import DesignSpaceProcessor
>>> processor = DesignSpaceProcessor()
>>> processor.read('/Users/mnakamura/Desktop/test.designspace')
>>> processor.generateUFO()
Traceback (most recent call last):
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/ufoLib/__init__.py", line 626, in _writePlist
    data = writePlistAtomically(data, path)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/ufoLib/__init__.py", line 1202, in writePlistAtomically
    writePlist(obj, f)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/plistlib.py", line 1017, in dump
    writer.write(value)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/plistlib.py", line 467, in write
    self.write_value(value)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/plistlib.py", line 490, in write_value
    self.write_dict(value)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/plistlib.py", line 537, in write_dict
    self.write_value(value)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/plistlib.py", line 505, in write_value
    raise TypeError("unsupported type: %s" % type(value))
TypeError: unsupported type: <class 'dict_items'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/designSpaceDocument/ufoProcessor.py", line 166, in generateUFO
    font.save(instanceDescriptor.path, self.ufoVersion)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/defcon/objects/font.py", line 743, in save
    self._saveLib(writer=writer, saveAs=saveAs, progressBar=progressBar)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/defcon/objects/font.py", line 837, in _saveLib
    self.saveLib(writer)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/defcon/objects/font.py", line 854, in saveLib
    writer.writeLib(libCopy)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/ufoLib/__init__.py", line 937, in writeLib
    self._writePlist(LIB_FILENAME, libDict)
  File "/Users/mnakamura/.pyenv/versions/3.5.3/lib/python3.5/site-packages/ufoLib/__init__.py", line 628, in _writePlist
    raise UFOLibError("The data for the file %s could not be written because it is not properly formatted." % fileName)
ufoLib.UFOLibError: The data for the file lib.plist could not be written because it is not properly formatted.
>>>
LettError commented 7 years ago

Merged.

mashabow commented 7 years ago

Thanks!