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


Python toml.dump方法代码示例

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


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

示例1: bundle_path

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def bundle_path(myapp, tmp_path):
    # Return the bundle path for the app; however, as a side effect,
    # ensure that the app, app_packages and support target directories
    # exist, and the briefcase index file has been created.
    bundle_path = tmp_path / 'tester' / '{myapp.app_name}.bundle'.format(myapp=myapp)
    (bundle_path / 'path' / 'to' / 'app').mkdir(parents=True, exist_ok=True)
    (bundle_path / 'path' / 'to' / 'app_packages').mkdir(parents=True, exist_ok=True)
    (bundle_path / 'path' / 'to' / 'support').mkdir(parents=True, exist_ok=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'app_packages_path': 'path/to/app_packages',
                'support_path': 'path/to/support',
            }
        }
        toml.dump(index, f)

    return bundle_path 
开发者ID:beeware,项目名称:briefcase,代码行数:21,代码来源:conftest.py

示例2: test_app_path

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_app_path(create_command, myapp):
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'app_packages_path': 'path/to/app_packages',
                'support_path': 'path/to/support',
            }
        }
        toml.dump(index, f)

    assert create_command.app_path(myapp) == bundle_path / 'path' / 'to' / 'app'

    # Requesting a second time should hit the cache,
    # so the briefcase file won't be needed.
    # Delete it to make sure the cache is used.
    (bundle_path / 'briefcase.toml').unlink()
    assert create_command.app_path(myapp) == bundle_path / 'path' / 'to' / 'app' 
开发者ID:beeware,项目名称:briefcase,代码行数:22,代码来源:test_properties.py

示例3: test_app_packages_path

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_app_packages_path(create_command, myapp):
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'app_packages_path': 'path/to/app_packages',
                'support_path': 'path/to/support',
            }
        }
        toml.dump(index, f)

    assert create_command.app_packages_path(myapp) == bundle_path / 'path' / 'to' / 'app_packages'

    # Requesting a second time should hit the cache,
    # so the briefcase file won't be needed.
    # Delete it to make sure the cache is used.
    (bundle_path / 'briefcase.toml').unlink()
    assert create_command.app_packages_path(myapp) == bundle_path / 'path' / 'to' / 'app_packages' 
开发者ID:beeware,项目名称:briefcase,代码行数:22,代码来源:test_properties.py

示例4: test_support_path

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_support_path(create_command, myapp):
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'app_packages_path': 'path/to/app_packages',
                'support_path': 'path/to/support',
            }
        }
        toml.dump(index, f)

    assert create_command.support_path(myapp) == bundle_path / 'path' / 'to' / 'support'

    # Requesting a second time should hit the cache,
    # so the briefcase file won't be needed.
    # Delete it to make sure the cache is used.
    (bundle_path / 'briefcase.toml').unlink()
    assert create_command.support_path(myapp) == bundle_path / 'path' / 'to' / 'support' 
开发者ID:beeware,项目名称:briefcase,代码行数:22,代码来源:test_properties.py

示例5: test_multiple_icon

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_multiple_icon(create_command, myapp):
    "If there are multiple icon targets, they're all in the target list"
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'icon': {
                    '10': 'path/to/icon-10.png',
                    '20': 'path/to/icon-20.png',
                },
            }
        }
        toml.dump(index, f)

    assert create_command.icon_targets(myapp) == {
        '10': 'path/to/icon-10.png',
        '20': 'path/to/icon-20.png',
    } 
开发者ID:beeware,项目名称:briefcase,代码行数:22,代码来源:test_properties.py

示例6: test_single_splash

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_single_splash(create_command, myapp):
    "If the splash target is specified as a single string, the splash list has one unsized entry"
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'splash': 'path/to/splash.png',
            }
        }
        toml.dump(index, f)

    assert create_command.splash_image_targets(myapp) == {
        None: 'path/to/splash.png'
    } 
开发者ID:beeware,项目名称:briefcase,代码行数:18,代码来源:test_properties.py

示例7: test_multiple_splash

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_multiple_splash(create_command, myapp):
    "If there are multiple splash targets, they're all in the target list"
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'splash': {
                    '10x20': 'path/to/splash-10.png',
                    '20x30': 'path/to/splash-20.png',
                },
            }
        }
        toml.dump(index, f)

    assert create_command.splash_image_targets(myapp) == {
        '10x20': 'path/to/splash-10.png',
        '20x30': 'path/to/splash-20.png',
    } 
开发者ID:beeware,项目名称:briefcase,代码行数:22,代码来源:test_properties.py

示例8: test_document_type_single_icon

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def test_document_type_single_icon(create_command, myapp):
    "If a doctype icon target is specified as a single string, the document_type_icons list has one unsized entry"
    bundle_path = create_command.bundle_path(myapp)
    bundle_path.mkdir(parents=True)
    with (bundle_path / 'briefcase.toml').open('w') as f:
        index = {
            'paths': {
                'app_path': 'path/to/app',
                'document_type_icon': {
                    'mydoc': 'path/to/mydoc-icon.png',
                    'other': 'path/to/otherdoc-icon.png',
                }
            }
        }
        toml.dump(index, f)

    assert create_command.document_type_icon_targets(myapp) == {
        'mydoc': {
            None: 'path/to/mydoc-icon.png',
        },
        'other': {
            None: 'path/to/otherdoc-icon.png',
        },
    } 
开发者ID:beeware,项目名称:briefcase,代码行数:26,代码来源:test_properties.py

示例9: _prepare_pyproject_toml

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def _prepare_pyproject_toml(addon_dir, org, repo):
    """Inject towncrier options in pyproject.toml"""
    pyproject_path = os.path.join(addon_dir, "pyproject.toml")
    with _preserve_file(pyproject_path):
        pyproject = {}
        if os.path.exists(pyproject_path):
            with open(pyproject_path) as f:
                pyproject = toml.load(f)
        if "tool" not in pyproject:
            pyproject["tool"] = {}
        pyproject["tool"]["towncrier"] = {
            "template": _get_towncrier_template(),
            "underlines": ["~"],
            "title_format": "{version} ({project_date})",
            "issue_format": _make_issue_format(org, repo),
            "directory": "readme/newsfragments",
            "filename": "readme/HISTORY.rst",
        }
        with open(pyproject_path, "w") as f:
            toml.dump(pyproject, f)
        yield 
开发者ID:OCA,项目名称:maintainer-tools,代码行数:23,代码来源:oca_towncrier.py

示例10: write_config

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def write_config(self) -> None:
        """Write leanpkg.toml for this project."""
        # Fix leanpkg lean_version bug if needed (the lean_version property
        # setter is working here, hence the weird line).
        self.lean_version = self.lean_version

        # Note we can't blindly use toml.dump because we need dict as values
        # for dependencies.
        with (self.directory/'leanpkg.toml').open('w') as cfg:
            cfg.write('[package]\n')
            cfg.write(toml.dumps(self.pkg_config))
            cfg.write('\n[dependencies]\n')
            for dep, val in self.deps.items():
                nval = str(val).replace("'git':", 'git =').replace(
                        "'rev':", 'rev =').replace("'", '"')
                cfg.write('{} = {}\n'.format(dep, nval)) 
开发者ID:leanprover-community,项目名称:mathlib-tools,代码行数:18,代码来源:lib.py

示例11: _save_settings

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def _save_settings(self):
        def stringify(conf):
            """Convert Path to str, even if it is buried deeply"""
            if isinstance(conf, Path):
                return str(conf)
            if isinstance(conf, Proc):
                return conf.name
            if isinstance(conf, dict):
                return {str(key): stringify(val) for key, val in conf.items()}
            if isinstance(conf, list):
                return [stringify(val) for val in conf]
            return str(conf)

        with open(self.workdir / 'proc.settings.toml', 'w') as fsettings:
            toml.dump({key: stringify(val)
                       for key, val in self.__attrs_property_raw__.items()
                       if key not in ('id', 'jobs', 'runtime_config')},
                      fsettings) 
开发者ID:pwwang,项目名称:PyPPL,代码行数:20,代码来源:proc.py

示例12: save

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def save(self, file):
        signature = inspect.signature(self.__init__)
        args_list = list(signature.parameters)
        args = {arg: getattr(self, arg) for arg in args_list}

        # add material characteristics so that the shaft element can be reconstructed
        # even if the material is not in the available_materials file.
        args["material"] = {
            "name": self.material.name,
            "rho": self.material.rho,
            "E": self.material.E,
            "G_s": self.material.G_s,
            "color": self.material.color,
        }

        try:
            data = toml.load(file)
        except FileNotFoundError:
            data = {}

        data[f"{self.__class__.__name__}_{self.tag}"] = args
        with open(file, "w") as f:
            toml.dump(data, f) 
开发者ID:ross-rotordynamics,项目名称:ross,代码行数:25,代码来源:shaft_element.py

示例13: save

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def save(self, file):
        """Save the rotor to a .toml file.

        Parameters
        ----------
        file : str or pathlib.Path

        Examples
        --------
        >>> from tempfile import tempdir
        >>> from pathlib import Path
        >>> # create path for temporary file
        >>> file = Path(tempdir) / 'rotor.toml'
        >>> rotor = rotor_example()
        >>> rotor.save(file)
        """
        with open(file, "w") as f:
            toml.dump({"parameters": self.parameters}, f)
        for el in self.elements:
            el.save(file) 
开发者ID:ross-rotordynamics,项目名称:ross,代码行数:22,代码来源:rotor_assembly.py

示例14: write_version_to_pyproject

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def write_version_to_pyproject(version: Version) -> None:
    """Dump a new version into the pyproject.toml."""

    import toml

    pyproject_file = pyproject_file_path()

    try:
        data = toml.load(pyproject_file)
        data["tool"]["poetry"]["version"] = str(version)
        with pyproject_file.open("w") as f:
            toml.dump(data, f)
    except (FileNotFoundError, TypeError):
        print(f"Unable to update {pyproject_file}: file not found.")
        sys.exit(1)
    except toml.TomlDecodeError:
        print(f"Unable to parse {pyproject_file}: incorrect TOML file.")
        sys.exit(1)

    check_call(["git", "add", str(pyproject_file.absolute())]) 
开发者ID:RasaHQ,项目名称:rasa-sdk,代码行数:22,代码来源:release.py

示例15: write_version_to_pyproject

# 需要导入模块: import toml [as 别名]
# 或者: from toml import dump [as 别名]
def write_version_to_pyproject(version: Version) -> None:
    """Dump a new version into the pyproject.toml."""
    pyproject_file = pyproject_file_path()

    try:
        data = toml.load(pyproject_file)
        data["tool"]["poetry"]["version"] = str(version)
        with pyproject_file.open("w", encoding="utf8") as f:
            toml.dump(data, f)
    except (FileNotFoundError, TypeError):
        print(f"Unable to update {pyproject_file}: file not found.")
        sys.exit(1)
    except toml.TomlDecodeError:
        print(f"Unable to parse {pyproject_file}: incorrect TOML file.")
        sys.exit(1)

    check_call(["git", "add", str(pyproject_file.absolute())]) 
开发者ID:botfront,项目名称:rasa-for-botfront,代码行数:19,代码来源:release.py


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