Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cffi/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 9 additions & 1 deletion sysrepo/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading