Commit 097412c
schema: enable getting node data path without list key
There is no way to get a node data path (path without choice/case)
without list keys.
Adds the path_type parameter to the SNode.schema_path() method. This
parameter can takes 3 values:
- SNode.PATH_LOG: returns the path with schema-only nodes (choice,
case) included, the default
- SNode.PATH_DATA: returns the path without schema-only nodes
- SNode.PATH_DATA_PATTERN: similar to PATH_DATA with list keys added
(the one used by data_path())
The SNode.PATH_LOG is set by default to not change the original
behavior.
The SNode.data_path() method now calls SNode.schema_path() with
self.PATH_DATA_PATTERN instead of lib.lysc_path().
Here is an example of the output difference between schema_path(),
data_path(), and schema_path(path_type=SNode.PATH_DATA) with a node
included in a choice and a list:
node.schema_path():
/ietf-keystore:keystore/asymmetric-keys/asymmetric-key/private-key-type/private-key/private-key
node.data_path() or node.schema_path(SNode.PATH_DATA_PATTERN):
/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']/private-key
node.schema_path(SNode.PATH_DATA):
/ietf-keystore:keystore/asymmetric-keys/asymmetric-key/private-key
Tests have been updated accordingly.
Signed-off-by: Matthieu Ternisien d'Ouville <matthieu.tdo@6wind.com>1 parent a2159c8 commit 097412c
2 files changed
+21
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1037 | 1041 | | |
1038 | 1042 | | |
1039 | 1043 | | |
| |||
1079 | 1083 | | |
1080 | 1084 | | |
1081 | 1085 | | |
1082 | | - | |
| 1086 | + | |
1083 | 1087 | | |
1084 | | - | |
| 1088 | + | |
1085 | 1089 | | |
1086 | 1090 | | |
1087 | 1091 | | |
1088 | 1092 | | |
1089 | 1093 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1098 | 1099 | | |
1099 | 1100 | | |
1100 | 1101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
286 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
290 | 293 | | |
291 | | - | |
| 294 | + | |
292 | 295 | | |
293 | 296 | | |
294 | 297 | | |
| |||
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
303 | | - | |
| 306 | + | |
304 | 307 | | |
305 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
306 | 311 | | |
307 | 312 | | |
308 | 313 | | |
| |||
0 commit comments