sample_python_ruamel_yaml.py 467 B

123456789101112131415161718192021222324252627
  1. from ruamel.yaml import YAML
  2. yaml_text = """
  3. Rootkey:
  4. - ListEntry
  5. AnotherRootKey: some-string
  6. ListRoot:
  7. - float-value: '1.0'
  8. int-value: 10234
  9. NestedList:
  10. - 1
  11. - 2
  12. - another-float: '1.1'
  13. another-int: 1111
  14. OneMoreRootKey: 9.99
  15. """
  16. # Tests the pure python based implementation
  17. yaml = YAML(typ='safe', pure=True)
  18. parsed = yaml.load(yaml_text)
  19. assert parsed['OneMoreRootKey'] == 9.99
  20. assert parsed['ListRoot'][1]['another-int'] == 1111