7 # Convert word from foo-bar to FooBar
8 # words begining with a digit will be converted to _digit
13 s = s[0].upper() + s[1:]
14 return re.sub(r'(?!^)-([a-zA-Z])', lambda m: m.group(1).upper(), s)
21 print 'yang2props.py <input yang> <output properties>'
24 with open(sys.argv[1], "r") as ins:
26 # if we see a leaf save the name for later
28 match = re.search(r'leaf (\S+)', line)
32 # if we see enum convert the value to enum format and see if it changed
33 # if the value is different write a property entry
35 match = re.search(r'enum "(\S+)";', line)
40 # see if converting to enum changed the string
42 property = "yang."+leaf+"."+enum+"="+val
43 if property not in li:
48 fo = open(sys.argv[2], "wb")
49 fo.write("# yang conversion properties \n")
50 fo.write("# used to convert Enum back to the original yang value \n")
51 fo.write("\n".join(li))