def check_dict_loading(request):
    test = '''
name: sample
age: sample
'''
    yaml_node = Yaml.from_str(test)
    print(yaml_node)
def check_list_loading(request):
    test = '''
- 12
- 34
'''

    yaml_node = Yaml.from_str(test)
    print(yaml_node)
def check_list_looping(request):
    test = '''
- Mumbai
- Bengaluru
- 
    something: 1
    another: string
'''
    yaml_node = Yaml.from_str(test)
    for item in yaml_node:
        print(item, type(item))
예제 #4
0
def check_join_construct(request):
    test = '''
    root: &BASE /path/to/root
    patha: !join [*BASE, a]
    pathb: !join [*BASE, b]
'''

    yaml_node = Yaml.from_str(test)
    assert yaml_node == {
        'root': '/path/to/root',
        'patha': '/path/to/roota',
        'pathb': '/path/to/rootb'
    }
예제 #5
0
파일: options.py 프로젝트: habin163/arjuna
    def from_str(cls,
                 *,
                 contents,
                 creation_context,
                 validate=True,
                 **replacements):
        for rname, rvalue in replacements.items():
            contents = contents.replace("${}$".format(rname), rvalue)

        contents_yaml = Yaml.from_str(contents)

        return cls.from_yaml(yaml_obj=contents_yaml,
                             creation_context=creation_context,
                             validate=validate)
예제 #6
0
    def from_str(cls, *, contents, creation_context, conf_stage, validate=True, **replacements):
        for rname, rvalue in replacements.items():
            contents = contents.replace("${}$".format(rname), rvalue)

        if not contents:
            return EditableConfig(
            arjuna_options_dict = dict(),
            user_options_dict = dict(),
            creation_context = "This configuration represents " + creation_context,
            )
        
        contents_yaml = Yaml.from_str(contents)

        return cls.from_yaml(yaml_obj=contents_yaml, creation_context=creation_context, conf_stage=conf_stage, validate=validate)
def check_dict_looping(request):
    test = '''
name: Mac
age: 21
cities: 
    - Mumbai
    - Bengaluru
    - Delhi
'''
    yaml_node = Yaml.from_str(test)
    for item in yaml_node:
        print(item, type(item))

    for section, item in yaml_node.items():
        print(section, item, type(item))