Advertisement
mazaya

Dis Parser

Sep 21st, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. # kalo ric00d jgn ganti author-nya doang bgst
  2. # 21-09-2019
  3.  
  4. class bodo_amat:
  5.     def __init__(self, file):
  6.         self.penentu = 0
  7.         self.d = []
  8.         self.k = []
  9.         self.file = file.splitlines()
  10.         start_stop = self.cari()
  11.         self.a1 = int(start_stop[0]) - 1
  12.         self.a2 = int(start_stop[1])
  13.         self.a3 = int(start_stop[2]) - 1
  14.         self.a4 = int(start_stop[3])
  15.        
  16.    
  17.     def cari(self):
  18.         hasil = []
  19.         a1 = 0
  20.         for s in self.file:
  21.             a1 += 1
  22.             try:
  23.                 ss = s.split("  ")[1]
  24.                 if str(ss) == "2":
  25.                     hasil.append(a1)
  26.                 elif str(ss) == "3":
  27.                     hasil.append(a1)
  28.                 elif str(ss) == "5":
  29.                     hasil.append(a1)
  30.                 elif str(ss) == "6":
  31.                     hasil.append(a1)
  32.                     break
  33.             except:
  34.                 pass
  35.         return hasil
  36.    
  37.     def parserD(self):
  38.         for s in range(self.a1, self.a2):
  39.             try:
  40.                 oh = self.file[s]
  41.                 ss = oh.split("(")[1].replace(")", "")
  42.                 if "LOAD_CONST" in oh:
  43.                     self.d.append(int(ss))
  44.             except:
  45.                 pass
  46.    
  47.     def parserK(self):
  48.         for s in range(self.a3, self.a4):
  49.             try:
  50.                 oh = self.file[s]
  51.                 ss = oh.split("(")[1].replace(")", "")
  52.                 if "LOAD_CONST" in oh:
  53.                     self.k.append(int(ss))
  54.             except:
  55.                 pass
  56.    
  57.    
  58.     def save(self, path):
  59.         open(path, 'w').write("d = " + str(self.d) +"\nk = " + str(self.k))
  60.  
  61. def home():
  62.     print("[ Dis Parser ]")
  63.     print("[ Coded by: SalisM3 ]")
  64.     buka = open(str(input("\n[?] Input File: "))).read()
  65.     simpen = str(input("[?] Output File: "))
  66.     gas = bodo_amat(buka)
  67.     gas.parserD()
  68.     gas.parserK()
  69.     gas.save(simpen)
  70.  
  71. home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement