| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import sys
- import pathlib
- test_file = pathlib.Path(__file__).absolute()
- test_dir = test_file.parent
- project_dir = test_dir.parent
- source_dir = project_dir / "src"
- sys.path.append(str(source_dir))
- import CxPini as pini
- first = pini.key()
- first.name = "first"
- first.value = 10
- second = pini.key()
- second.name = "other"
- second.value = "This is other key"
- last = pini.key()
- last.name = "last"
- last.value = 20
- last.comment = "And with comment"
- sample = pini.section()
- sample.add_comment("This is very basic library. ")
- sample.add_comment("It could be used as very very very nice. ")
- sample.add_comment("It is possible to split this very long comments auto.")
- sample.add_comment("I think it is very nice. You have not to do it Yourself.")
- sample.name = "Section"
- sample.add_key(first)
- sample.add_key(second)
- sample.add_key(last)
- print(sample)
- if sample.get("first").value != 10:
- print("Can not get first.")
- if not sample.exists("second"):
- print("Second can not be found.")
- if not sample.get("last").value != 20:
- print("Last return bad content.")
- if sample.exists("jiojoijio"):
- print("Key which not exists is returned.")
|