Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ exceptiongroup==1.3.0
gitdb==4.0.12
GitPython==3.1.45
iniconfig==2.1.0
jsonpath-ng==1.7.0
loguru==0.7.3
-e .
packaging==25.0
pip-tools==7.5.0
pluggy==1.6.0
ply==3.11
Pygments==2.19.2
pyproject_hooks==1.2.0
pytest==8.4.1
Expand Down
8 changes: 8 additions & 0 deletions src/mncpyexamples/asynchello/helloasync.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""Basic asyncio usage examples.

Copyright (c) 2025 Markus Neifer
Licensed under the MIT License.
See file LICENSE in project root directory.
"""
import asyncio

async def main():
"""Say hello asynchronously."""
print('Hello ...')
await asyncio.sleep(1)
print('... World!')

def run_main():
"""Run the main asynchronous function."""
asyncio.run(main())

if __name__ == "__main__":
Expand Down
25 changes: 25 additions & 0 deletions src/mncpyexamples/jsonhello/jsonpath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Basic JSONPath usage examples.

Copyright (c) 2025 Markus Neifer
Licensed under the MIT License.
See file LICENSE in project root directory.

See https://github.com/h2non/jsonpath-ng
"""
import jsonpath_ng as jp

def parse_no_space():
"""Parse JSONPath without spaces."""
jsonpath_expr = jp.parse('foo[*].baz')

return [match.value for match in jsonpath_expr.find({'foo': [{'baz': 1}, {'baz': 2}]})]

def parse_with_space():
"""Parse JSONPath with spaces."""
jsonpath_expr = jp.parse('"foo bar"[*].baz')

return [match.value for match in jsonpath_expr.find({'foo bar': [{'baz': 1}, {'baz': 2}]})]

if __name__ == '__main__':
print('parse_no_space:', parse_no_space())
print('parse_with_space:', parse_with_space())
10 changes: 9 additions & 1 deletion tests/test_helloasync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""Test the helloasync module.

Copyright (c) 2025 Markus Neifer
Licensed under the MIT License.
See file LICENSE in project root directory.
"""
from mncpyexamples.asynchello import helloasync

def test_helloasync(capsys):
import mncpyexamples.asynchello.helloasync as helloasync
"""Test the run_main() function."""
helloasync.run_main()
captured = capsys.readouterr()
assert captured.out == "Hello ...\n... World!\n"
17 changes: 17 additions & 0 deletions tests/test_jsonpath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Test the jsonpath module.

Copyright (c) 2025 Markus Neifer
Licensed under the MIT License.
See file LICENSE in project root directory.
"""
from mncpyexamples.jsonhello import jsonpath

def test_parse_no_space():
"""Test JSONPath parsing without spaces."""
result = jsonpath.parse_no_space()
assert result == [1, 2]

def test_parse_with_space():
"""Test JSONPath parsing with spaces."""
result = jsonpath.parse_with_space()
assert result == [1, 2]