当前位置: 首页>>代码示例>>Python>>正文


Python InstanceContainer.getMetaData方法代码示例

本文整理汇总了Python中UM.Settings.InstanceContainer.InstanceContainer.getMetaData方法的典型用法代码示例。如果您正苦于以下问题:Python InstanceContainer.getMetaData方法的具体用法?Python InstanceContainer.getMetaData怎么用?Python InstanceContainer.getMetaData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UM.Settings.InstanceContainer.InstanceContainer的用法示例。


在下文中一共展示了InstanceContainer.getMetaData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_roundtrip_instance

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
def test_roundtrip_instance(tmpdir, process_count, loaded_container_registry):
    definition = loaded_container_registry.findDefinitionContainers(id = "inherits")[0]

    instance_container = InstanceContainer("test_container")
    instance_container.setName("Test Instance Container")
    instance_container.setDefinition(definition)
    instance_container.addMetaDataEntry("test", "test")
    instance_container.setProperty("test_setting_1", "value", 20)

    temp_file = tmpdir.join("instance_container_test")

    mp_run(process_count, write_data, temp_file, instance_container)

    assert len(list(tmpdir.listdir())) == 1

    results = mp_run(process_count, read_data, temp_file)

    for result in results:
        deserialized_container = InstanceContainer("test_container")
        deserialized_container.setDefinition(definition)
        deserialized_container.deserialize(result)

        assert deserialized_container.getName() == instance_container.getName()
        assert deserialized_container.getMetaData() == instance_container.getMetaData()
        assert deserialized_container.getProperty("test_setting_1", "value") == instance_container.getProperty("test_setting_1", "value")
开发者ID:senttech,项目名称:Uranium,代码行数:27,代码来源:TestRoundtripping.py

示例2: findAllQualitiesForMachineMaterial

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
    def findAllQualitiesForMachineMaterial(self, machine_definition: "DefinitionContainerInterface", material_container: InstanceContainer) -> List[InstanceContainer]:
        criteria = {"type": "quality"}
        result = self._getFilteredContainersForStack(machine_definition, [material_container.getMetaData()], **criteria)
        if not result:
            basic_materials = self._getBasicMaterialMetadatas(material_container.getMetaData())
            if basic_materials:
                result = self._getFilteredContainersForStack(machine_definition, basic_materials, **criteria)

        return result
开发者ID:olemis,项目名称:Cura,代码行数:11,代码来源:QualityManager.py

示例3: definition_changes_container

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
def definition_changes_container() -> InstanceContainer:
    definition_changes_container = InstanceContainer(container_id = "Test Definition Changes")
    definition_changes_container.setMetaDataEntry("type", "definition_changes")
    # Add current setting version to the instance container
    from cura.CuraApplication import CuraApplication
    definition_changes_container.getMetaData()["setting_version"] = CuraApplication.SettingVersion
    return definition_changes_container
开发者ID:rwreynolds,项目名称:Cura,代码行数:9,代码来源:conftest.py

示例4: _updateMetaData

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
    def _updateMetaData(self, container: InstanceContainer) -> None:
        index = self.find("id", container.id)

        if self._section_property:
            self.setProperty(index, "section", container.getMetaDataEntry(self._section_property, ""))

        self.setProperty(index, "metadata", container.getMetaData())
        self.setProperty(index, "name", container.getName())
        self.setProperty(index, "id", container.getId())
开发者ID:Ultimaker,项目名称:Uranium,代码行数:11,代码来源:InstanceContainersModel.py

示例5: _configureProfile

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
    def _configureProfile(self, profile: InstanceContainer, id_seed: str, new_name: str) -> Optional[str]:
        profile.setDirty(True)  # Ensure the profiles are correctly saved

        new_id = self.createUniqueName("quality_changes", "", id_seed, catalog.i18nc("@label", "Custom profile"))
        profile._id = new_id
        profile.setName(new_name)

        if "type" in profile.getMetaData():
            profile.setMetaDataEntry("type", "quality_changes")
        else:
            profile.addMetaDataEntry("type", "quality_changes")

        quality_type = profile.getMetaDataEntry("quality_type")
        if not quality_type:
            return catalog.i18nc("@info:status", "Profile is missing a quality type.")

        quality_type_criteria = {"quality_type": quality_type}
        if self._machineHasOwnQualities():
            profile.setDefinition(self._activeQualityDefinition().getId())
            if self._machineHasOwnMaterials():
                active_material_id = self._activeMaterialId()
                if active_material_id and active_material_id != "empty":  # only update if there is an active material
                    profile.addMetaDataEntry("material", active_material_id)
                    quality_type_criteria["material"] = active_material_id

            quality_type_criteria["definition"] = profile.getDefinition().getId()

        else:
            profile.setDefinition(fdmprinter)
            quality_type_criteria["definition"] = "fdmprinter"

        machine_definition = Application.getInstance().getGlobalContainerStack().getBottom()
        del quality_type_criteria["definition"]

        # materials = None

        if "material" in quality_type_criteria:
            # materials = ContainerRegistry.getInstance().findInstanceContainers(id = quality_type_criteria["material"])
            del quality_type_criteria["material"]

        # Do not filter quality containers here with materials because we are trying to import a profile, so it should
        # NOT be restricted by the active materials on the current machine.
        materials = None

        # Check to make sure the imported profile actually makes sense in context of the current configuration.
        # This prevents issues where importing a "draft" profile for a machine without "draft" qualities would report as
        # successfully imported but then fail to show up.
        from cura.QualityManager import QualityManager
        qualities = QualityManager.getInstance()._getFilteredContainersForStack(machine_definition, materials, **quality_type_criteria)
        if not qualities:
            return catalog.i18nc("@info:status", "Could not find a quality type {0} for the current configuration.", quality_type)

        ContainerRegistry.getInstance().addContainer(profile)

        return None
开发者ID:olemis,项目名称:Cura,代码行数:57,代码来源:CuraContainerRegistry.py

示例6: test_findInstanceContainers

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
def test_findInstanceContainers(container_registry, data):
    for container in data["containers"]: # Fill the registry with mock containers.
        container = container.copy()
        container_id = container["id"]
        del container["id"]
        instance_container = InstanceContainer(container_id)
        for key, value in container.items(): # Copy data into metadata.
            instance_container.getMetaData()[key] = value
        container_registry.addContainer(instance_container)

    results = container_registry.findInstanceContainers(**data["filter"]) # The actual function call we're testing.

    _verifyMetaDataMatches(results, data["result"])
开发者ID:senttech,项目名称:Uranium,代码行数:15,代码来源:TestContainerRegistry.py

示例7: _configureProfile

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
    def _configureProfile(self, profile: InstanceContainer, id_seed: str, new_name: str) -> Optional[str]:
        profile.setReadOnly(False)
        profile.setDirty(True)  # Ensure the profiles are correctly saved

        new_id = self.createUniqueName("quality_changes", "", id_seed, catalog.i18nc("@label", "Custom profile"))
        profile._id = new_id
        profile.setName(new_name)

        if "type" in profile.getMetaData():
            profile.setMetaDataEntry("type", "quality_changes")
        else:
            profile.addMetaDataEntry("type", "quality_changes")

        quality_type = profile.getMetaDataEntry("quality_type")
        if not quality_type:
            return catalog.i18nc("@info:status", "Profile is missing a quality type.")

        quality_type_criteria = {"quality_type": quality_type}
        if self._machineHasOwnQualities():
            profile.setDefinition(self._activeQualityDefinition())
            if self._machineHasOwnMaterials():
                active_material_id = self._activeMaterialId()
                if active_material_id:  # only update if there is an active material
                    profile.addMetaDataEntry("material", active_material_id)
                    quality_type_criteria["material"] = active_material_id

            quality_type_criteria["definition"] = profile.getDefinition().getId()

        else:
            profile.setDefinition(ContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")[0])
            quality_type_criteria["definition"] = "fdmprinter"

        # Check to make sure the imported profile actually makes sense in context of the current configuration.
        # This prevents issues where importing a "draft" profile for a machine without "draft" qualities would report as
        # successfully imported but then fail to show up.
        qualities = self.findInstanceContainers(**quality_type_criteria)
        if not qualities:
            return catalog.i18nc("@info:status", "Could not find a quality type {0} for the current configuration.", quality_type)

        ContainerRegistry.getInstance().addContainer(profile)

        return None
开发者ID:senttech,项目名称:Cura,代码行数:44,代码来源:CuraContainerRegistry.py

示例8: _configureProfile

# 需要导入模块: from UM.Settings.InstanceContainer import InstanceContainer [as 别名]
# 或者: from UM.Settings.InstanceContainer.InstanceContainer import getMetaData [as 别名]
    def _configureProfile(self, profile: InstanceContainer, id_seed: str, new_name: str, machine_definition_id: str) -> Optional[str]:
        profile.setDirty(True)  # Ensure the profiles are correctly saved

        new_id = self.createUniqueName("quality_changes", "", id_seed, catalog.i18nc("@label", "Custom profile"))
        profile.setMetaDataEntry("id", new_id)
        profile.setName(new_name)

        # Set the unique Id to the profile, so it's generating a new one even if the user imports the same profile
        # It also solves an issue with importing profiles from G-Codes
        profile.setMetaDataEntry("id", new_id)
        profile.setMetaDataEntry("definition", machine_definition_id)

        if "type" in profile.getMetaData():
            profile.setMetaDataEntry("type", "quality_changes")
        else:
            profile.setMetaDataEntry("type", "quality_changes")

        quality_type = profile.getMetaDataEntry("quality_type")
        if not quality_type:
            return catalog.i18nc("@info:status", "Profile is missing a quality type.")

        global_stack = Application.getInstance().getGlobalContainerStack()
        if global_stack is None:
            return None
        definition_id = getMachineDefinitionIDForQualitySearch(global_stack.definition)
        profile.setDefinition(definition_id)

        # Check to make sure the imported profile actually makes sense in context of the current configuration.
        # This prevents issues where importing a "draft" profile for a machine without "draft" qualities would report as
        # successfully imported but then fail to show up.
        quality_manager = cura.CuraApplication.CuraApplication.getInstance()._quality_manager
        quality_group_dict = quality_manager.getQualityGroupsForMachineDefinition(global_stack)
        if quality_type not in quality_group_dict:
            return catalog.i18nc("@info:status", "Could not find a quality type {0} for the current configuration.", quality_type)

        ContainerRegistry.getInstance().addContainer(profile)

        return None
开发者ID:Ultimaker,项目名称:Cura,代码行数:40,代码来源:CuraContainerRegistry.py


注:本文中的UM.Settings.InstanceContainer.InstanceContainer.getMetaData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。