Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information