SHARE
TWEET

Untitled

VTsilaLETImogila Nov 9th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import mainParse
  2. f = open('lol.json', 'r', encoding = "utf-8")
  3. objects='message '
  4. all_value='required'
  5. tip1='string'
  6. tip2='uint32'
  7. newline=''
  8. def types(s):
  9.     if isinstance(s,str):
  10.         l='string'
  11.         return l
  12.     else:
  13.         l='uint32'
  14.         return l
  15.  
  16. string=""
  17. lines=f.readlines()
  18. lines = [line.rstrip() for line in lines]
  19. for line in lines:
  20.     string1="".join(line)
  21.     string=string+string1
  22. w=open('kek.proto', 'w', encoding="utf-8")
  23. s=mainParse.parse(string)
  24.  
  25. keysdouble2=[]
  26. def cinvert(dic,t,h):
  27.     keys = []
  28.     for key in dic:
  29.         keys.append(key)
  30.     for i in range(0,len(keys)):
  31.         if isinstance(dic[keys[i]],dict)==True:
  32.             w.write('\t'*t+objects+keys[i]+' {'+'\n')
  33.             if len(keys)==1:
  34.                 t+=1
  35.             cinvert(dic[keys[i]],t,h)
  36.             w.write('\t'*t+'}'+'\n')
  37.         elif isinstance(dic[keys[i]],dict) == False:
  38.             h+=1
  39.             w.write('\t'*(t+1)+'required'+' '+types(dic[keys[i]])+' '+ keys[i]+'='+str(h)+';'+'\n')
  40.  
  41.  
  42. print(s)
  43. cinvert(s,0,0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top