03-pini.py 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import sys
  2. import pathlib
  3. test_file = pathlib.Path(__file__).absolute()
  4. test_dir = test_file.parent
  5. project_dir = test_dir.parent
  6. source_dir = project_dir / "src"
  7. sys.path.append(str(source_dir))
  8. import CxPini as pini
  9. f1 = pini.key()
  10. f1.name = "x"
  11. f1.value = 20
  12. f2 = pini.key()
  13. f2.name = "y"
  14. f2.value = 30
  15. f3 = pini.key()
  16. f3.name = "z"
  17. f4 = pini.key()
  18. f4.name = "a"
  19. f4.value = "VALUE"
  20. f4.comment = "This is key comment."
  21. global_section = pini.section()
  22. global_section.comment = "This is global section."
  23. global_section.add(f2)
  24. global_section.add(f1)
  25. other_section = pini.section()
  26. other_section.name = "Other"
  27. other_section.comment = "This is other section."
  28. other_section.add(f3)
  29. other_section.add(f4)
  30. other_section.add(f1)
  31. last_section = pini.section()
  32. last_section.name = "last"
  33. last_section.comment = "This is very last section."
  34. last_section.add(f1)
  35. last_section.add(f2)
  36. test = pini.pini()
  37. test.add(global_section)
  38. test.add(other_section)
  39. test.add(last_section)
  40. print(test)