Skip to content

Commit 20acf8c

Browse files
committed
pylint reformatting
1 parent b5bdeb9 commit 20acf8c

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

libyang/context.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,22 +685,25 @@ def find_leafref_path_target_paths(self, leafref_path: str) -> List[str]:
685685
raise self.error("leafref_path not found")
686686

687687
node_set = ffi.new("struct ly_set **")
688-
if (lib.lysc_node_lref_targets(node, node_set) != lib.LY_SUCCESS or
689-
node_set[0] == ffi.NULL or node_set[0].count == 0):
688+
if (
689+
lib.lysc_node_lref_targets(node, node_set) != lib.LY_SUCCESS
690+
or node_set[0] == ffi.NULL
691+
or node_set[0].count == 0):
690692
raise self.error("leafref_path does not contain any leafref targets")
691693

692694
node_set = node_set[0]
693695
for i in range(node_set.count):
694-
path = lib.lysc_path(node_set.snodes[i], lib.LYSC_PATH_DATA, ffi.NULL, 0);
696+
path = lib.lysc_path(node_set.snodes[i], lib.LYSC_PATH_DATA, ffi.NULL, 0)
695697
out.append(c2str(path))
696698
lib.free(path)
697699

698700
lib.ly_set_free(node_set, ffi.NULL)
699701

700702
return out
701703

702-
703-
def find_backlinks_paths(self, match_path: str = None, match_ancestors: bool = False) -> List[str]:
704+
def find_backlinks_paths(
705+
self, match_path: str = None, match_ancestors: bool = False
706+
) -> List[str]:
704707
"""
705708
Search entire schema for nodes that contain leafrefs and return as a
706709
list of schema node paths.
@@ -739,13 +742,18 @@ def find_backlinks_paths(self, match_path: str = None, match_ancestors: bool = F
739742
raise self.error("match_path not found")
740743

741744
node_set = ffi.new("struct ly_set **")
742-
if (lib.lysc_node_lref_backlinks(self.cdata, match_node, match_ancestors, node_set)
743-
!= lib.LY_SUCCESS or node_set[0] == ffi.NULL or node_set[0].count == 0):
745+
if (
746+
lib.lysc_node_lref_backlinks(
747+
self.cdata, match_node, match_ancestors, node_set
748+
)
749+
!= lib.LY_SUCCESS
750+
or node_set[0] == ffi.NULL
751+
or node_set[0].count == 0):
744752
raise self.error("backlinks not found")
745753

746754
node_set = node_set[0]
747755
for i in range(node_set.count):
748-
path = lib.lysc_path(node_set.snodes[i], lib.LYSC_PATH_DATA, ffi.NULL, 0);
756+
path = lib.lysc_path(node_set.snodes[i], lib.LYSC_PATH_DATA, ffi.NULL, 0)
749757
out.append(c2str(path))
750758
lib.free(path)
751759

tests/test_schema.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -807,38 +807,42 @@ def setUp(self):
807807
self.ctx = Context(YANG_DIR)
808808
self.ctx.load_module("yolo-leafref-search")
809809
self.ctx.load_module("yolo-leafref-search-extmod")
810+
810811
def tearDown(self):
811812
self.ctx.destroy()
812813
self.ctx = None
814+
813815
def test_backlinks_all_nodes(self):
814816
expected = [
815817
"/yolo-leafref-search-extmod:my_extref_list/my_extref",
816818
"/yolo-leafref-search:refstr",
817819
"/yolo-leafref-search:refnum",
818-
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union"
820+
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union",
819821
]
820822
refs = self.ctx.find_backlinks_paths()
821823
expected.sort()
822824
refs.sort()
823825
self.assertEqual(expected, refs)
826+
824827
def test_backlinks_one(self):
825828
expected = [
826829
"/yolo-leafref-search-extmod:my_extref_list/my_extref",
827830
"/yolo-leafref-search:refstr",
828-
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union"
831+
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union",
829832
]
830833
refs = self.ctx.find_backlinks_paths(
831834
match_path="/yolo-leafref-search:my_list/my_leaf_string"
832835
)
833836
expected.sort()
834837
refs.sort()
835838
self.assertEqual(expected, refs)
839+
836840
def test_backlinks_children(self):
837841
expected = [
838842
"/yolo-leafref-search-extmod:my_extref_list/my_extref",
839843
"/yolo-leafref-search:refstr",
840844
"/yolo-leafref-search:refnum",
841-
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union"
845+
"/yolo-leafref-search-extmod:my_extref_list/my_extref_union",
842846
]
843847
refs = self.ctx.find_backlinks_paths(
844848
match_path="/yolo-leafref-search:my_list",
@@ -847,10 +851,9 @@ def test_backlinks_children(self):
847851
expected.sort()
848852
refs.sort()
849853
self.assertEqual(expected, refs)
854+
850855
def test_backlinks_leafref_target_paths(self):
851-
expected = [
852-
"/yolo-leafref-search:my_list/my_leaf_string"
853-
]
856+
expected = ["/yolo-leafref-search:my_list/my_leaf_string"]
854857
refs = self.ctx.find_leafref_path_target_paths(
855858
"/yolo-leafref-search-extmod:my_extref_list/my_extref"
856859
)

0 commit comments

Comments
 (0)