summaryrefslogtreecommitdiffhomepage
path: root/tools/pyang_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pyang_plugins')
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py
index 0ab5ab59..1f6ee7d0 100644
--- a/tools/pyang_plugins/bgpyang2golang.py
+++ b/tools/pyang_plugins/bgpyang2golang.py
@@ -168,6 +168,8 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix):
# case leafref
elif type_name == 'leafref':
+ if type_obj.search_one('path').arg.startswith('../config'):
+ continue
t = dig_leafref(type_obj)
if is_translation_required(t):
print >> o, ' //%s:%s\'s original type is %s' \
@@ -243,7 +245,10 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix):
l = t.i_children[0]
emit_type_name = '[]' + l.golang_name
equal_type = EQUAL_TYPE_MAP
- equal_data = t.i_children[0].search_one('key').arg
+ equal_data = l.search_one('key').arg
+ leaf = l.search_one('leaf').search_one('type')
+ if leaf.arg == 'leafref' and leaf.search_one('path').arg.startswith('../config'):
+ equal_data = 'config.' + equal_data
else:
emit_type_name = t.golang_name
equal_type = EQUAL_TYPE_CONTAINER
@@ -692,9 +697,9 @@ def translate_type(key):
# 'hoge-hoge' -> 'HogeHoge'
def convert_to_golang(type_string):
- a = type_string.split('-')
+ a = type_string.split('.')
a = map(lambda x: x.capitalize(), a) # XXX locale sensitive
- return ''.join(a)
+ return '.'.join( ''.join(t.capitalize() for t in x.split('-')) for x in a)
# 'hoge-hoge' -> 'HOGE_HOGE'