當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。