diff --git a/cffi/cdefs.h b/cffi/cdefs.h index 6e61c62..869b156 100644 --- a/cffi/cdefs.h +++ b/cffi/cdefs.h @@ -52,6 +52,7 @@ typedef enum { SR_CTX_DEFAULT, SR_CTX_NO_PRINTED, SR_CTX_SET_PRIV_PARSED, + SR_CTX_COMPILE_OBSOLETE, ... } sr_context_flag_t; diff --git a/sysrepo/connection.py b/sysrepo/connection.py index 42d3253..78ced29 100644 --- a/sysrepo/connection.py +++ b/sysrepo/connection.py @@ -36,7 +36,12 @@ class SysrepoConnection: __slots__ = ("cdata",) - def __init__(self, cache_running: bool = False, not_printed: bool = True): + def __init__( + self, + cache_running: bool = False, + not_printed: bool = True, + compile_obsolete: bool = False, + ): """ :arg cache_running: Always cache running datastore data which makes mainly repeated retrieval of @@ -49,6 +54,9 @@ def __init__(self, cache_running: bool = False, not_printed: bool = True): if not_printed: ctx_flags |= lib.SR_CTX_NO_PRINTED + if compile_obsolete: + ctx_flags |= lib.SR_CTX_COMPILE_OBSOLETE + # mandatory flag to work with libyang-python ctx_flags |= lib.SR_CTX_SET_PRIV_PARSED diff --git a/tests/test_connection.py b/tests/test_connection.py index 1d4b528..f46c94f 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -93,3 +93,9 @@ def test_conn_start_session_with_printed_context(self): sess = conn.start_session() self.assertEqual(sess.get_datastore(), "running") sess.stop() + + def test_conn_start_session_compile_obsolete(self): + with sysrepo.SysrepoConnection(compile_obsolete=True) as conn: + sess = conn.start_session() + self.assertEqual(sess.get_datastore(), "running") + sess.stop()