Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Merge 73a66ee into c9cdf79
Browse files Browse the repository at this point in the history
  • Loading branch information
bewing committed Mar 30, 2017
2 parents c9cdf79 + 73a66ee commit f8511c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions napalm_yang/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ def __init__(self, model, device=None, profile=None, is_config=None,
self.extra_vars = extra_vars or {}

if self.mapping and device:
device_config = self._execute_methods(device,
device_output = self._execute_methods(device,
self.mapping["metadata"].get("execute", []))

else:
device_config = []
device_output = []

native = native or []

self.native = []

for n in native + device_config:
for n in native + device_output:
self.native.append(n.replace("\r", "")) # Parsing will be easier

if not self.native:
raise Exception("I don't have any data to operate with")

self.bookmarks = {self._yang_name: self.native, "parent": self.native}
self.bookmarks = bookmarks or self.bookmarks

if self.mapping:
self.parser = helpers.get_parser(self.mapping["metadata"]["parser"])

self.bookmarks = {self._yang_name: self.native, "parent": self.native}
self.bookmarks = bookmarks or self.bookmarks

def _execute_methods(self, device, methods):
result = []
for m in methods:
Expand All @@ -67,6 +67,7 @@ def _execute_methods(self, device, methods):
def parse(self):
if not self.mapping:
return
self.native = self.parser.init_native(self.native)
self._parse(self._yang_name, self.model, self.mapping[self._yang_name])

def _parse(self, attribute, model, mapping):
Expand Down
4 changes: 2 additions & 2 deletions napalm_yang/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class BaseParser(object):

@classmethod
def init_config(cls, config):
return config
def init_native(cls, native):
return native

@classmethod
def parse_list(cls, mapping):
Expand Down

0 comments on commit f8511c3

Please sign in to comment.