File: listl3.py

package info (click to toggle)
python-hiyapyco 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: python: 2,012; makefile: 237
file content (50 lines) | stat: -rwxr-xr-x 1,527 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env python

import sys
import os
import logging
import pprint

basepath = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.dirname(basepath))
import hiyapyco

logger = logging.getLogger()
logging.basicConfig(
        level=logging.DEBUG,
        format='%(levelname)s\t[%(name)s] %(funcName)s: %(message)s'
        )

print('='*10, 'method=hiyapyco.METHOD_SIMPLE', '='*10)
conf = hiyapyco.load(
        os.path.join(basepath, 'listl31.yaml'),
        os.path.join(basepath, 'listl32.yaml'),
        failonmissingfiles=True
        )
print('-'*10, 'DATA', '-'*10)
print(conf)
print('-'*10, 'PPRINT', '-'*10)
pprint.PrettyPrinter(indent=4).pprint(conf)
print('-'*10, 'YAML', '-'*10)
print(hiyapyco.dump(conf))
print('-'*10, 'EOF', '-'*10)
assert conf['l3'] == [{'a': 'aaa', 'c': 'c'}, {'b': 'BBB', 'c': 'CCC'}, {'a': 'x', 'b': 'y', 'c': 'z'}]

print('='*10, 'method=hiyapyco.METHOD_MERGE', '='*10)
conf = hiyapyco.load(
        os.path.join(basepath, 'listl31.yaml'),
        os.path.join(basepath, 'listl32.yaml'),
        method=hiyapyco.METHOD_MERGE,
        failonmissingfiles=True
        )
print('-'*10, 'DATA', '-'*10)
print(conf)
print('-'*10, 'PPRINT', '-'*10)
pprint.PrettyPrinter(indent=4).pprint(conf)
print('-'*10, 'YAML', '-'*10)
print(hiyapyco.dump(conf))
print('-'*10, 'EOF', '-'*10)
assert conf['l3'] == [{'a': 'aaa', 'b': 'b', 'c': 'c'}, {'a': 'A', 'b': 'BBB', 'c': 'CCC'}, {'a': 'x', 'b': 'y', 'c': 'z'}]

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent nu