Skip to content

Commit 0ebaafd

Browse files
committed
Make parse_xpath_to_gnmi_path a classmethod
1 parent 227baf7 commit 0ebaafd

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/cisco_gnmi/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ def subscribe_xpaths(
402402
subscription_list.subscription.extend(subscriptions)
403403
return self.subscribe([subscription_list])
404404

405-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
405+
@classmethod
406+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
406407
"""Parses an XPath to proto.gnmi_pb2.Path.
407408
This function should be overridden by any child classes for origin logic.
408409

src/cisco_gnmi/nx.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def subscribe_xpaths(
152152
heartbeat_interval,
153153
)
154154

155-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
155+
@classmethod
156+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
156157
"""Attempts to determine whether origin should be YANG (device) or DME.
157158
Errors on OpenConfig until support is present.
158159
"""
@@ -169,4 +170,4 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
169170
xpath = xpath.split(":", 1)[1]
170171
else:
171172
origin = "DME"
172-
return super(NXClient, self).parse_xpath_to_gnmi_path(xpath, origin)
173+
return super(NXClient, cls).parse_xpath_to_gnmi_path(xpath, origin)

src/cisco_gnmi/xe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def subscribe_xpaths(
307307
heartbeat_interval,
308308
)
309309

310-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
310+
@classmethod
311+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
311312
"""Naively tries to intelligently (non-sequitur!) origin
312313
Otherwise assume rfc7951
313314
legacy is not considered
@@ -318,4 +319,4 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
318319
origin = "openconfig"
319320
else:
320321
origin = "rfc7951"
321-
return super(XEClient, self).parse_xpath_to_gnmi_path(xpath, origin)
322+
return super(XEClient, cls).parse_xpath_to_gnmi_path(xpath, origin)

src/cisco_gnmi/xr.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ def subscribe_xpaths(
338338
heartbeat_interval,
339339
)
340340

341-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
341+
@classmethod
342+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
342343
"""No origin specified implies openconfig
343344
Otherwise origin is expected to be the module name
344345
"""
@@ -351,9 +352,10 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
351352
# module name
352353
origin, xpath = xpath.split(":", 1)
353354
origin = origin.strip("/")
354-
return super(XRClient, self).parse_xpath_to_gnmi_path(xpath, origin)
355+
return super(XRClient, cls).parse_xpath_to_gnmi_path(xpath, origin)
355356

356-
def parse_cli_to_gnmi_path(self, command):
357+
@classmethod
358+
def parse_cli_to_gnmi_path(cls, command):
357359
"""Parses a CLI command to proto.gnmi_pb2.Path.
358360
IOS XR appears to be the only OS with this functionality.
359361

0 commit comments

Comments
 (0)