66from typing import IO , Any , Dict , Iterator , Optional , Tuple , Union
77
88from _libyang import ffi , lib
9- from .util import IOType , c2str , init_output , ly_array_iter , str2c
9+ from .util import IOType , LibyangError , c2str , init_output , ly_array_iter , str2c
1010
1111
1212# -------------------------------------------------------------------------------------
@@ -44,7 +44,6 @@ def printer_flags(
4444
4545# -------------------------------------------------------------------------------------
4646class Module :
47-
4847 __slots__ = ("context" , "cdata" )
4948
5049 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -228,7 +227,6 @@ def parse_data_dict(
228227
229228# -------------------------------------------------------------------------------------
230229class Revision :
231-
232230 __slots__ = ("context" , "cdata" , "module" )
233231
234232 def __init__ (self , context : "libyang.Context" , cdata , module ):
@@ -272,7 +270,6 @@ def __str__(self):
272270
273271# -------------------------------------------------------------------------------------
274272class Extension :
275-
276273 __slots__ = ("context" , "cdata" )
277274
278275 def __init__ (self , context : "libyang.Context" , cdata , module_parent : Module = None ):
@@ -295,7 +292,6 @@ def __str__(self):
295292
296293# -------------------------------------------------------------------------------------
297294class ExtensionParsed (Extension ):
298-
299295 __slots__ = ("module_parent" ,)
300296
301297 def __init__ (self , context : "libyang.Context" , cdata , module_parent : Module = None ):
@@ -318,7 +314,6 @@ def module(self) -> Module:
318314
319315# -------------------------------------------------------------------------------------
320316class ExtensionCompiled (Extension ):
321-
322317 __slots__ = ("cdata_def" ,)
323318
324319 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -336,7 +331,6 @@ def module(self) -> Module:
336331
337332# -------------------------------------------------------------------------------------
338333class _EnumBit :
339-
340334 __slots__ = ("context" , "cdata" )
341335
342336 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -388,7 +382,6 @@ class Bit(_EnumBit):
388382
389383# -------------------------------------------------------------------------------------
390384class Type :
391-
392385 __slots__ = ("context" , "cdata" , "cdata_parsed" )
393386
394387 UNKNOWN = lib .LY_TYPE_UNKNOWN
@@ -609,7 +602,6 @@ def __str__(self):
609602
610603# -------------------------------------------------------------------------------------
611604class Feature :
612-
613605 __slots__ = ("context" , "cdata" )
614606
615607 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -653,7 +645,6 @@ def __str__(self):
653645
654646# -------------------------------------------------------------------------------------
655647class IfFeatureExpr :
656-
657648 __slots__ = ("context" , "cdata" , "module_features" , "compiled" )
658649
659650 def __init__ (self , context : "libyang.Context" , cdata , module_features = None ):
@@ -692,7 +683,7 @@ def get_feature(name):
692683 for feature in self .module_features :
693684 if feature .name () == name :
694685 return feature .cdata
695- raise Exception ("No feature %s in module" % name )
686+ raise LibyangError ("No feature %s in module" % name )
696687
697688 def parse_iffeature (tokens ):
698689 def oper2 (op ):
@@ -789,7 +780,6 @@ def __str__(self):
789780
790781# -------------------------------------------------------------------------------------
791782class IfFeature (IfFeatureExprTree ):
792-
793783 __slots__ = ("context" , "cdata" )
794784
795785 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -812,7 +802,6 @@ def __str__(self):
812802
813803# -------------------------------------------------------------------------------------
814804class IfNotFeature (IfFeatureExprTree ):
815-
816805 __slots__ = ("context" , "child" )
817806
818807 def __init__ (self , context : "libyang.Context" , child : IfFeatureExprTree ):
@@ -831,7 +820,6 @@ def __str__(self):
831820
832821# -------------------------------------------------------------------------------------
833822class IfAndFeatures (IfFeatureExprTree ):
834-
835823 __slots__ = ("context" , "a" , "b" )
836824
837825 def __init__ (
@@ -856,7 +844,6 @@ def __str__(self):
856844
857845# -------------------------------------------------------------------------------------
858846class IfOrFeatures (IfFeatureExprTree ):
859-
860847 __slots__ = ("context" , "a" , "b" )
861848
862849 def __init__ (
@@ -881,7 +868,6 @@ def __str__(self):
881868
882869# -------------------------------------------------------------------------------------
883870class SNode :
884-
885871 __slots__ = ("context" , "cdata" , "cdata_parsed" )
886872
887873 CONTAINER = lib .LYS_CONTAINER
@@ -1076,7 +1062,6 @@ def new(context: "libyang.Context", cdata) -> "SNode":
10761062# -------------------------------------------------------------------------------------
10771063@SNode .register (SNode .LEAF )
10781064class SLeaf (SNode ):
1079-
10801065 __slots__ = ("cdata_leaf" , "cdata_leaf_parsed" )
10811066
10821067 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -1123,7 +1108,6 @@ def __str__(self):
11231108# -------------------------------------------------------------------------------------
11241109@SNode .register (SNode .LEAFLIST )
11251110class SLeafList (SNode ):
1126-
11271111 __slots__ = ("cdata_leaflist" , "cdata_leaflist_parsed" )
11281112
11291113 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -1176,7 +1160,6 @@ def __str__(self):
11761160# -------------------------------------------------------------------------------------
11771161@SNode .register (SNode .CONTAINER )
11781162class SContainer (SNode ):
1179-
11801163 __slots__ = ("cdata_container" , "cdata_container_parsed" )
11811164
11821165 def __init__ (self , context : "libyang.Context" , cdata ):
@@ -1209,7 +1192,6 @@ def children(self, types: Optional[Tuple[int, ...]] = None) -> Iterator[SNode]:
12091192# -------------------------------------------------------------------------------------
12101193@SNode .register (SNode .LIST )
12111194class SList (SNode ):
1212-
12131195 __slots__ = ("cdata_list" , "cdata_list_parsed" )
12141196
12151197 def __init__ (self , context : "libyang.Context" , cdata ):
0 commit comments