Skip to content

Commit

Permalink
Resolved issue CiscoDevNet#839
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Gorelik committed Dec 12, 2018
1 parent 9770669 commit 039fab6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion sdk/python/core/tests/test_non_top_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
from ydk.ext.types import Empty, EncodingFormat
from ydk.filters import YFilter

from ydk.models.ydktest.ydktest_sanity import Runner, ChildIdentity, YdkEnumTest
try:
from ydk.models.ydktest.ydktest_sanity import Runner, ChildIdentity, YdkEnumTest
except:
from ydk.models.ydktest.ydktest_sanity.runner.runner import Runner
from ydk.models.ydktest.ydktest_sanity.ydktest_sanity import ChildIdentity, YdkEnumTest

class SanityTest(unittest.TestCase):

Expand Down
15 changes: 10 additions & 5 deletions sdk/python/core/ydk/entity_utils/entity_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ def _datanode_to_entity(data_node):
yang_ns = importlib.import_module('ydk.models.{}._yang_ns'.format(name))
entity_lookup = yang_ns.__dict__['ENTITY_LOOKUP']
if (module, container) in entity_lookup:
# print("name='{}', module='{}', container='{}', lookup='{}'".format(name, module, container, entity_lookup[(module, container)]))
module_name, class_name = entity_lookup[(module, container)].split('.', 1)
# print("module_name='{}', entity_class='{}'".format(mod, class_name))
imported_module = importlib.import_module('ydk.models.{}.{}'.format(name, module_name))
entity = getattr(imported_module, class_name)()
entity_entry = entity_lookup[(module, container)]
name_list = entity_entry.split('.')
class_name = name_list[-1]
module_name = entity_entry.split('.'+class_name)[0]
try:
imported_module = importlib.import_module('ydk.models.{}.{}'.format(name, module_name))
entity = getattr(imported_module, class_name)()
except:
raise YModelError("Failed instantiate class '{}' from module '{}'".format(class_name, module_name))

top_entity = entity.clone_ptr()
get_entity_from_data_node(data_node, top_entity);
return top_entity
Expand Down

0 comments on commit 039fab6

Please sign in to comment.