Skip to content

Commit 3152983

Browse files
authored
Merge pull request #63 from cisco-ie/xpath-parse-classmethod
parse_xpath_to_gnmi_path as classmethod
2 parents fa89ea8 + b037789 commit 3152983

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/cisco_gnmi/client.py

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

411-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
411+
@classmethod
412+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
412413
"""Parses an XPath to proto.gnmi_pb2.Path.
413414
This function should be overridden by any child classes for origin logic.
414415

src/cisco_gnmi/nx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def subscribe_xpaths(
289289
heartbeat_interval,
290290
)
291291

292-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
292+
@classmethod
293+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
293294
"""Attempts to determine whether origin should be YANG (device) or DME.
294295
"""
295296
if origin is None:

src/cisco_gnmi/xe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ def subscribe_xpaths(
312312
prefix
313313
)
314314

315-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
315+
@classmethod
316+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
316317
"""Naively tries to intelligently (non-sequitur!) origin
317318
Otherwise assume rfc7951
318319
legacy is not considered
@@ -323,4 +324,4 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
323324
origin = "openconfig"
324325
else:
325326
origin = "rfc7951"
326-
return super(XEClient, self).parse_xpath_to_gnmi_path(xpath, origin)
327+
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)