aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-06-26 10:59:43 +0200
committerThéo de la Hogue2024-06-26 10:59:43 +0200
commit986c7e8d0b16f2b8e7f28824b3e1fbd5d5b2236e (patch)
treee27e28167e277136e5b2aa35acc9f3a592d502b5
parentdb4c1466c70e69de8d19cb4b01dd1f31bfc36978 (diff)
downloadargaze-986c7e8d0b16f2b8e7f28824b3e1fbd5d5b2236e.zip
argaze-986c7e8d0b16f2b8e7f28824b3e1fbd5d5b2236e.tar.gz
argaze-986c7e8d0b16f2b8e7f28824b3e1fbd5d5b2236e.tar.bz2
argaze-986c7e8d0b16f2b8e7f28824b3e1fbd5d5b2236e.tar.xz
Renaming patch function into edit function. Documenting the edit function.
-rw-r--r--docs/user_guide/utils/ready-made_scripts.md12
-rw-r--r--src/argaze/__main__.py16
2 files changed, 18 insertions, 10 deletions
diff --git a/docs/user_guide/utils/ready-made_scripts.md b/docs/user_guide/utils/ready-made_scripts.md
index 5d34bff..bc35d59 100644
--- a/docs/user_guide/utils/ready-made_scripts.md
+++ b/docs/user_guide/utils/ready-made_scripts.md
@@ -9,9 +9,9 @@ Collection of command-line scripts to provide useful features.
!!! note
*Use -h option to get command arguments documentation.*
-## ArContext handler
+## Load ArContext JSON configuration
-Load and execute any ArContext from a JSON CONFIGURATION file
+Load and execute any [ArContext](../../argaze.md/#argaze.ArFeatures.ArContext) from a JSON CONFIGURATION file
```shell
python -m argaze load CONFIGURATION
@@ -46,6 +46,14 @@ echo "context.pause()" > /tmp/argaze
echo "context.resume()" > /tmp/argaze
```
+## Edit JSON configuration
+
+Modify the content of JSON CONFIGURATION file with another JSON CHANGES file then, save the result into an OUTPUT file
+
+```shell
+python -m argaze edit CONFIGURATION CHANGES OUTPUT
+```
+
## ArUco markers group exporter
Detect DICTIONARY and SIZE ArUco markers inside a MOVIE frame then, export detected ArUco markers group as .obj file into an OUTPUT folder.
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py
index cb8bd01..926d572 100644
--- a/src/argaze/__main__.py
+++ b/src/argaze/__main__.py
@@ -268,20 +268,20 @@ def load_context(args):
logging.info('%s pipe closed', args.pipe_path)
-def patch_file(args):
+def edit_file(args):
"""
- Patch a JSON file according a JSON patch into a JSON output file.
+ Edit a JSON file according a JSON changes file into a JSON output file.
"""
# Open JSON files
- with open(args.file) as file, open(args.patch) as patch, open(args.output, 'w', encoding='utf-8') as output:
+ with open(args.file) as file, open(args.changes) as changes, open(args.output, 'w', encoding='utf-8') as output:
import collections.abc
import json
# Load unique object
file_data = json.load(file)
- patch_data = json.load(patch)
+ changes_data = json.load(changes)
def update(d, u):
@@ -301,7 +301,7 @@ def patch_file(args):
return d
- new_data = update(file_data, patch_data)
+ new_data = update(file_data, changes_data)
# Write new data
json.dump(new_data, output, ensure_ascii=False, indent=' ')
@@ -318,11 +318,11 @@ parser_load.add_argument('-x', '--display', metavar='DISPLAY', nargs="+", type=i
parser_load.add_argument('--no-window', action='store_true', default=False, help='disable window mode')
parser_load.set_defaults(func=load_context)
-parser_patch = subparsers.add_parser('patch', help=patch_file.__doc__)
+parser_patch = subparsers.add_parser('edit', help=edit_file.__doc__)
parser_patch.add_argument('file', metavar='FILE', type=str, default=None, help='json file path')
-parser_patch.add_argument('patch', metavar='PATCH', type=str, default=None, help='json patch path')
+parser_patch.add_argument('changes', metavar='CHANGES', type=str, default=None, help='json changes path')
parser_patch.add_argument('output', metavar='OUTPUT', type=str, default=None, help='json output path')
-parser_patch.set_defaults(func=patch_file)
+parser_patch.set_defaults(func=edit_file)
args = parser.parse_args()
args.func(args)