__init__.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from . import XmlMaterialProfile
  4. from . import XmlMaterialUpgrader
  5. from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
  6. from UM.i18n import i18nCatalog
  7. catalog = i18nCatalog("cura")
  8. upgrader = XmlMaterialUpgrader.XmlMaterialUpgrader()
  9. def getMetaData():
  10. return {
  11. "settings_container": {
  12. "type": "material",
  13. "mimetype": "application/x-ultimaker-material-profile"
  14. },
  15. "version_upgrade": {
  16. ("materials", 1000000): ("materials", 1000004, upgrader.upgradeMaterial),
  17. },
  18. "sources": {
  19. "materials": {
  20. "get_version": upgrader.getXmlVersion,
  21. "location": {"./materials"}
  22. },
  23. }
  24. }
  25. def register(app):
  26. # add Mime type
  27. mime_type = MimeType(
  28. name = "application/x-ultimaker-material-profile",
  29. comment = "Ultimaker Material Profile",
  30. suffixes = [ "xml.fdm_material" ]
  31. )
  32. MimeTypeDatabase.addMimeType(mime_type)
  33. # add upgrade version
  34. from cura.CuraApplication import CuraApplication
  35. from UM.VersionUpgradeManager import VersionUpgradeManager
  36. VersionUpgradeManager.getInstance().registerCurrentVersion(
  37. ("materials", XmlMaterialProfile.XmlMaterialProfile.Version * 1000000 + CuraApplication.SettingVersion),
  38. (CuraApplication.ResourceTypes.MaterialInstanceContainer, "application/x-ultimaker-material-profile")
  39. )
  40. return {"version_upgrade": upgrader,
  41. "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"),
  42. }