How to use the snapcraft.yaml_utils.load function in snapcraft

To help you get started, we’ve selected a few snapcraft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snapcore / snapcraft / tests / integration / general / View on Github external
def test_curl_exists_and_properly_defined(self):
        """Curl is used in most of the demos so we test for its existence."""
        output = self.run_snapcraft(["define", "curl"])

        expected_prefix = (
            "Maintainer: 'Sergio Schvezov '\n"
            "Description: A tool and a library (usable from many languages) "
            "for client side URL transfers, supporting FTP, FTPS, HTTP, "
            "HTTPS, TELNET, DICT, FILE and LDAP.\n\n"
        self.assertThat(output, Contains(expected_prefix))
        idx = output.index(expected_prefix) + len(expected_prefix)
        part = yaml_utils.load(output[idx:])
        expected_part = {
            "curl": {
                "plugin": "autotools",
                "source": "",
                "source-type": "tar",
                "configflags": [
                "snap": [
github snapcore / snapcraft / tests / unit / View on Github external
def test_ordereddict_yaml(self):
        from collections import OrderedDict

        data = OrderedDict()

        data["name"] = "test"
        data["description"] = "description"

        output = yaml_utils.dump(data)

        self.assertTrue(isinstance(yaml_utils.load(output), OrderedDict))
github snapcore / snapcraft / tests / unit / states / View on Github external
def test_yaml_conversion(self, init_spy):
        state_string = yaml_utils.dump(self.state)

        # Verify that the dumped tag was correct
        self.assertThat(state_string.splitlines()[0], Equals("!PrimeState"))

        # Now verify the conversion
        state_from_yaml = yaml_utils.load(state_string)
        self.assertThat(state_from_yaml, Equals(self.state))

        # Verify that init was not called
github snapcore / snapcraft / snapcraft / cli / View on Github external
def _edit_developers(developers: List[Dict[str, str]]) -> List[Dict[str, str]]:
    """Spawn an editor to modify the snap-developer assertion for a snap."""
    editor_cmd = os.getenv("EDITOR", "vi")

    developer_wrapper = {"developers": developers}

    with tempfile.NamedTemporaryFile() as ft:
        with open(, "w") as fw:
            print(_COLLABORATION_HEADER, file=fw)
            yaml_utils.dump(developer_wrapper, stream=fw)
        with open(, "r") as fr:
            developers = yaml_utils.load(fr).get("developers")
    return developers
github snapcore / snapcraft / snapcraft / internal / lifecycle / View on Github external
def _snap_data_from_dir(directory):
    with open(os.path.join(directory, "meta", "snap.yaml")) as f:
        snap = yaml_utils.load(f)

    return {
        "name": snap["name"],
        "version": snap["version"],
        "arch": snap.get("architectures", []),
        "type": snap.get("type", ""),
        "license": snap.get("license"),
github snapcore / snapcraft / snapcraft / internal / meta / View on Github external
def from_file(cls, snap_yaml_path: str) -> "Snap":
        with open(snap_yaml_path, "r") as f:
            snap_dict = yaml_utils.load(f)
            return cls.from_dict(snap_dict=snap_dict)
github snapcore / snapcraft / snapcraft / internal / build_providers / View on Github external
def _load_info(self) -> Dict[str, Any]:
        filepath = os.path.join(self.provider_project_dir, "project-info.yaml")
        if not os.path.exists(filepath):
            return dict()

        with open(filepath) as info_file:
            return yaml_utils.load(info_file)
github snapcore / snapcraft / snapcraft / internal / View on Github external
def __init__(self):

        if not os.path.exists(self.parts_yaml):

        with open(self.parts_yaml) as parts_file:
            self._parts = yaml_utils.load(parts_file)