
from . import VersionUpgrade21to22

from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")

def getMetaData():
    return {
        "plugin": {
            "name": catalog.i18nc("@label", "Version Upgrade 2.1 to 2.2"),
            "author": "Ultimaker",
            "version": "1.0",
            "description": catalog.i18nc("@info:whatsthis", "Upgrades configurations from Cura 2.1 to Cura 2.2."),
            "api": 2
        },
        "version_upgrade": {
            "profile": {
                "from": 1,
                "to": 2
            },
            "machine_instance": {
                "from": 1,
                "to": 2
            }
        }
    }

def register(app):
    return { "version_upgrade": VersionUpgrade21to22.VersionUpgrade21to22() }


from . import VersionUpgrade21to22

from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")

def getMetaData():
    return {
        "plugin": {
            "name": catalog.i18nc("@label", "Version Upgrade 2.1 to 2.2"),
            "author": "Ultimaker",
            "version": "1.0",
            "description": catalog.i18nc("@info:whatsthis", "Upgrades configurations from Cura 2.1 to Cura 2.2."),
            "api": 2
        },
        "version_upgrade": {
            # From                   To                        Upgrade function
            ("profile", 1):          ("instance_container", 2, VersionUpgrade21to22.upgradeProfile),
            ("machine_instance", 1): ("container_stack", 2,    VersionUpgrade21to22.upgradeMachineInstance),
            ("preferences", 1):      ("preferences", 2,        VersionUpgrade21to22.upgradePreferences)
        },
        "sources": {
            "profile": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"./profiles"}
            },
            "machine_instance": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"./machine_instances"}
            },
            "preferences": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"."}
            }
        }
    }

def register(app):
    return { "version_upgrade": VersionUpgrade21to22.VersionUpgrade21to22() }

Update metadata with dynamic config types
Update metadata with dynamic config types

After settings rework, we decided to make the upgrade plug-ins define their own configuration types. This is basically the definition for these configuration types. Only the get_version function is not yet implemented.

Contributes to issue CURA-844.

  
  from . import VersionUpgrade21to22
  
  from UM.i18n import i18nCatalog
  catalog = i18nCatalog("cura")
  
  def getMetaData():
      return {
          "plugin": {
              "name": catalog.i18nc("@label", "Version Upgrade 2.1 to 2.2"),
              "author": "Ultimaker",
              "version": "1.0",
              "description": catalog.i18nc("@info:whatsthis", "Upgrades configurations from Cura 2.1 to Cura 2.2."),
              "api": 2
          },
          "version_upgrade": {
+             # From                   To                        Upgrade function
+             ("profile", 1):          ("instance_container", 2, VersionUpgrade21to22.upgradeProfile),
+             ("machine_instance", 1): ("container_stack", 2,    VersionUpgrade21to22.upgradeMachineInstance),
+             ("preferences", 1):      ("preferences", 2,        VersionUpgrade21to22.upgradePreferences)
+         },
+         "sources": {
              "profile": {
-                 "from": 1,
-                 "to": 2
+                 "get_version": VersionUpgrade21to22.getCfgVersion,
+                 "location": {"./profiles"}
              },
              "machine_instance": {
-                 "from": 1,
+                 "get_version": VersionUpgrade21to22.getCfgVersion,
+                 "location": {"./machine_instances"}
+             },
+             "preferences": {
+                 "get_version": VersionUpgrade21to22.getCfgVersion,
-                 "to": 2
+                 "location": {"."}
              }
          }
      }
  
  def register(app):
      return { "version_upgrade": VersionUpgrade21to22.VersionUpgrade21to22() }
  
Update metadata with dynamic config types
## Code Before:

from . import VersionUpgrade21to22

from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")

def getMetaData():
    return {
        "plugin": {
            "name": catalog.i18nc("@label", "Version Upgrade 2.1 to 2.2"),
            "author": "Ultimaker",
            "version": "1.0",
            "description": catalog.i18nc("@info:whatsthis", "Upgrades configurations from Cura 2.1 to Cura 2.2."),
            "api": 2
        },
        "version_upgrade": {
            "profile": {
                "from": 1,
                "to": 2
            },
            "machine_instance": {
                "from": 1,
                "to": 2
            }
        }
    }

def register(app):
    return { "version_upgrade": VersionUpgrade21to22.VersionUpgrade21to22() }

## Instruction:
Update metadata with dynamic config types
## Code After:

from . import VersionUpgrade21to22

from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")

def getMetaData():
    return {
        "plugin": {
            "name": catalog.i18nc("@label", "Version Upgrade 2.1 to 2.2"),
            "author": "Ultimaker",
            "version": "1.0",
            "description": catalog.i18nc("@info:whatsthis", "Upgrades configurations from Cura 2.1 to Cura 2.2."),
            "api": 2
        },
        "version_upgrade": {
            # From                   To                        Upgrade function
            ("profile", 1):          ("instance_container", 2, VersionUpgrade21to22.upgradeProfile),
            ("machine_instance", 1): ("container_stack", 2,    VersionUpgrade21to22.upgradeMachineInstance),
            ("preferences", 1):      ("preferences", 2,        VersionUpgrade21to22.upgradePreferences)
        },
        "sources": {
            "profile": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"./profiles"}
            },
            "machine_instance": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"./machine_instances"}
            },
            "preferences": {
                "get_version": VersionUpgrade21to22.getCfgVersion,
                "location": {"."}
            }
        }
    }

def register(app):
    return { "version_upgrade": VersionUpgrade21to22.VersionUpgrade21to22() }
