redruin1 / factorio-draftsman

A complete, well-tested, and up-to-date module to manipulate Factorio blueprint strings. Compatible with mods.
MIT License
94 stars 17 forks source link

`class...blueprint has no attribute 'description'` when reading bp string with description #41

Closed rpdelaney closed 2 years ago

rpdelaney commented 2 years ago

bp string has a description:

0eNqllNuOozAMhl8lytWuBCOgnMqr7FRVAJdaCglKwnQ6Fe8+Tumy2i6jbTWICxLb/+fYxBdeyxEGg8rx6sJbsI3BwaFWvOInYPaoR9myDhw7CaNQdZaJWo+O/ZBwcMxpZrA7up/Vq3pVIRvVoE9goGU1iEYrdkJ3ZEqzXrejBLvm4/e+9r6zwOEAjWMGGsA3MFcXYS30tQSzeJEZB+ABR4q1vPp14RY7JaQ/pDuTqeLooCcPJXq/mjF8ohDVwjuv4mkXcFAOHcKscF2c92rsazDksMSCpJQMNiEoMN05pGKCOYjGJzBoi3M5L5xUwzzfBvxMH2WZEqwe6Txmb/GDhOJoeabgH17yJ1fswoU5aLnKKaLfnIQ4CqhL1Dfjj7LZrchvnpPPv5ZPgnQNkD4HSMvn8s/uW7miWcYv2U212L5k04pM/oBMUf4tE1z/JevtdgBow/n3DTfUtDVG8Qgj+m+q5QMyefS9VLcPMNJvliOOFsjtJtOYCXvRHFH5qDVkdled3Qz1eS7zLOBS1EBXnpMgjSqwfs8PjatUUsZpsU2KLKc3LafpExROpg4=

Blueprint object does not include it:

>>> from draftsman.blueprintable import get_blueprintable_from_string
>>> with open("lint.txt") as f:
...     lint = f.read()
>>> b = get_blueprintable_from_string(lint)
/home/ryan/src/me/factorio-rails-cleaner/.venv/lib/python3.10/site-packages/draftsman/blueprintable.py:40: DraftsmanWarning: <class 'draftsman.classes.blueprint.Blueprint'> has no attribute 'description'
  return Blueprint(blueprint_string)
>>> b.description
>>> b.description is None
True
>>>
redruin1 commented 2 years ago

I was wondering how I missed such a basic parameter, but It turns out that this page I was using as a reference is just straight up missing these keys; someone should probably fix that. Perhaps me, since I'm so familiar with the format. Proper loading of the description attribute, as well as it's integration into the test suite, was added for Blueprint, as well as BlueprintBook. This will be in version 1.0.2.