01-key.py 973 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. check = pini.key()
  10. count = 0
  11. def dump():
  12. global count
  13. global check
  14. count = count + 1
  15. print("Dump: " + str(count))
  16. print("Key: " + str(check.name))
  17. print("Value: " + str(check.value))
  18. print("Value type: " + str(check.value_type))
  19. print("Comment: " + str(check.comment))
  20. print("Result: ")
  21. print(str(check))
  22. print()
  23. dump()
  24. check.comment = "Sample"
  25. dump()
  26. check.name = "key"
  27. dump()
  28. check.value = " value"
  29. dump()
  30. check.value = 10
  31. dump()
  32. check.name = None
  33. dump()
  34. check.name = "key"
  35. dump()
  36. print("Get result: " + str(check.get(20)))
  37. print()
  38. check.value = "other"
  39. dump()
  40. print("Get result: " + str(check.get("def")))
  41. print()
  42. check.value = None
  43. dump()
  44. print("Get result: " + str(check.get("def")))
  45. print()