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


Python World.get_infos方法代码示例

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


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

示例1: OnImportOndisk

# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import get_infos [as 别名]
    def OnImportOndisk(self, e):
        """Import a world on disk."""
        choose_file = t("ui.button.choose_file")
        extensions = "Zip archive (*.zip)|*.zip"
        dialog = wx.FileDialog(None, choose_file,
                "", "", extensions, wx.OPEN)
        result = dialog.ShowModal()
        if result == wx.ID_OK:
            filename = dialog.GetPath()

            # Try to install the world from the archive
            archive = ZipFile(filename)
            files = {name: archive.read(name) for name in archive.namelist()}
            options = files.get("world/options.conf")
            if options:
                infos = World.get_infos(options)
                name = infos.get("connection", {}).get("name")
                wizard = InstallWorld(self.engine, name, files)
                wizard.start()
开发者ID:vlegoff,项目名称:cocomud,代码行数:21,代码来源:window.py

示例2: start

# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import get_infos [as 别名]
    def start(self):
        """Display the UI, or assume default values.

        The process of installing a world when connected to a
        user interface is as follows:

        1. The world to install or merge into is sought out.
        2. A dialog to select merging options is displayed.
        3. The installation dialog is displayed.

        """
        logger.info("Starting the wizard 'install_world' for '{}'".format(self.name))

        # 1. Look for the world, if any
        best = self.engine.get_world(self.name)
        worlds = []
        worlds = [self.engine.create_world(self.name)]
        if best is not None:
            worlds.insert(0, best)

        # Add the other worlds
        others = []
        for other in self.engine.worlds.values():
            if other not in worlds:
                others.append(other)

        others.sort(key=lambda w: w.name)
        worlds += others

        # 2. Create the dialog to select merging options
        if self.ui:
            logger.debug("Opening the PreInstallDialog")
            dialog = PreInstallDialog(self.engine, self.name, worlds)
            results = dialog.results
            dialog.ShowModal()
            destination = results.get("world")
            merge = results.get("merge")
            name = results.get("name")
            logger.debug("Obtained the settings: {}".format(results))
            if destination is None or merge is None:
                return

            # If the world hasn't a location or name
            if not destination.name:
                destination.name = name
                destination.location = name.lower()

            self.engine.prepare_world(destination, merge)
            destination.load()
        else:
            destination = worlds[0]
            merge = merging[0]
            name = destination.name

        # 3. Show the installation dialog
        if self.ui:
            logger.debug("Opening the installation dialog")
            self.dialog = UI(self.engine, self)
            data = self.dialog.data
            self.dialog.ShowModal()
            logger.debug("Obtained data={}".format(data))
        else:
            data = {}
            install = self.files.get("world/install.json")
            if install:
                values = json.loads(install, encoding="latin-1", object_pairs_hook=OrderedDict)

                for key, value in values.items():
                    default = value.get("default")
                    data[key] = default

        self.engine.prepare_world(destination, merge)
        sharp = destination.sharp_engine

        # Copy the options
        options = self.files.get("world/options.conf")
        if options:
            infos = World.get_infos(options)
            hostname = infos.get("connection", {}).get("hostname")
            port = int(infos.get("connection", {}).get("port"))
            destination.name = infos.get("connection", {}).get("name")
            destination.hostname = hostname
            destination.port = port

        # Install the world
        if "world/install.py" in self.files:
            logger.debug("Executing the installation file")
            install = self.files["world/install.py"]
            install = install.decode("latin-1").replace("\r", "")
            globals = sharp.globals
            locals = sharp.locals
            locals.update(data)
            exec(install, globals, locals)

        # Execute the 'config.set' file as is
        config = self.files.get("world/config.set")
        if config:
            logger.debug("Executing the config.set script")
            config = config.decode("latin-1")
            destination.sharp_engine.execute(config, variables=False)
#.........这里部分代码省略.........
开发者ID:vlegoff,项目名称:cocomud,代码行数:103,代码来源:install_world.py


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