GithubHelp home page GithubHelp logo

Comments (3)

tanbro avatar tanbro commented on August 10, 2024

Thanks for the nice advice!

I think the tag can be used in YAML multiple documents.

eg:

# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, unicode_literals
from typing import Iterable

import unittest

from textwrap import dedent

import yaml

from yamlinclude import YamlIncludeConstructor

YAML1 = {'name': '1'}
YAML2 = {'name': '2'}

class MultiLoaderTestCase(unittest.TestCase):

    constructor = YamlIncludeConstructor()

    def setUp(self):
        yaml.add_constructor('!include', self.constructor)

    def test_full_load_all_yaml(self):
        txt = dedent('''
        ---
        file1: !include tests/data/include.d/1.yaml

        ---
        file2: !include tests/data/include.d/2.yaml

        ''')

        iterable = yaml.full_load_all(txt)
        for i, data in enumerate(iterable):
            if i == 0:
                self.assertEqual(data, {'file1': YAML1})
            elif i == 1:
                self.assertEqual(data, {'file2': YAML2})
            else:
                raise RuntimeError()

This tag/constructor woks in yaml.load_all

the testcase was add in commit f972a5e

from pyyaml-include.

elvis2 avatar elvis2 commented on August 10, 2024

Thank you for the example.

What version of yamlinclude are you using in the example?

from pyyaml-include.

tanbro avatar tanbro commented on August 10, 2024

The testcase can run on statble version :-)

from pyyaml-include.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.