def print_mem( self, fmt: str, with_siblings: bool = False, pretty: bool = False, include_implicit_defaults: bool = False, trim_default_values: bool = False, keep_empty_containers: bool = False, ) -> Union[str, bytes]: flags = printer_flags( with_siblings=with_siblings, pretty=pretty, include_implicit_defaults=include_implicit_defaults, trim_default_values=trim_default_values, keep_empty_containers=keep_empty_containers, ) buf = ffi.new("char **") fmt = data_format(fmt) ret = lib.lyd_print_mem(buf, self.cdata, fmt, flags) if ret != 0: raise self.context.error("cannot print node") try: if fmt == lib.LYD_LYB: # binary format, do not convert to unicode return c2str(buf[0], decode=False) return c2str(buf[0], decode=True) finally: lib.free(buf[0])
def print_mem(self, fmt='tree', path=None): fmt = schema_out_format(fmt) buf = ffi.new('char **') ret = lib.lys_print_mem(buf, self._module, fmt, str2c(path), 0, 0) if ret != 0: raise self.context.error('cannot print module') try: return c2str(buf[0]) finally: lib.free(buf[0])
def print_mem( self, fmt: str = "tree", path: Optional[str] = None ) -> Union[str, bytes]: fmt = schema_out_format(fmt) buf = ffi.new("char **") ret = lib.lys_print_mem(buf, self.cdata, fmt, str2c(path), 0, 0) if ret != 0: raise self.context.error("cannot print module") try: return c2str(buf[0]) finally: lib.free(buf[0])
def path(self) -> str: path = lib.lyd_path(self.cdata) try: return c2str(path) finally: lib.free(path)
def path(self): path = lib.lyd_path(self._node) try: return c2str(path) finally: lib.free(path)
def data_path(self, key_placeholder="'%s'"): try: s = lib.lys_data_path_pattern(self._node, str2c(key_placeholder)) return c2str(s) finally: lib.free(s)
def schema_path(self): try: s = lib.lys_path(self._node, 0) return c2str(s) finally: lib.free(s)
def schema_path(self) -> str: try: s = lib.lys_path(self.cdata, 0) return c2str(s) finally: lib.free(s)