Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: enable getting node data path without list key #78

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

MatthieuTdO-6WIND
Copy link
Contributor

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

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 <[email protected]>
@rjarry rjarry merged commit 097412c into CESNET:master Jan 24, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants