Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # kalo ric00d jgn ganti author-nya doang bgst
- # 21-09-2019
- class bodo_amat:
- def __init__(self, file):
- self.penentu = 0
- self.d = []
- self.k = []
- self.file = file.splitlines()
- start_stop = self.cari()
- self.a1 = int(start_stop[0]) - 1
- self.a2 = int(start_stop[1])
- self.a3 = int(start_stop[2]) - 1
- self.a4 = int(start_stop[3])
- def cari(self):
- hasil = []
- a1 = 0
- for s in self.file:
- a1 += 1
- try:
- ss = s.split(" ")[1]
- if str(ss) == "2":
- hasil.append(a1)
- elif str(ss) == "3":
- hasil.append(a1)
- elif str(ss) == "5":
- hasil.append(a1)
- elif str(ss) == "6":
- hasil.append(a1)
- break
- except:
- pass
- return hasil
- def parserD(self):
- for s in range(self.a1, self.a2):
- try:
- oh = self.file[s]
- ss = oh.split("(")[1].replace(")", "")
- if "LOAD_CONST" in oh:
- self.d.append(int(ss))
- except:
- pass
- def parserK(self):
- for s in range(self.a3, self.a4):
- try:
- oh = self.file[s]
- ss = oh.split("(")[1].replace(")", "")
- if "LOAD_CONST" in oh:
- self.k.append(int(ss))
- except:
- pass
- def save(self, path):
- open(path, 'w').write("d = " + str(self.d) +"\nk = " + str(self.k))
- def home():
- print("[ Dis Parser ]")
- print("[ Coded by: SalisM3 ]")
- buka = open(str(input("\n[?] Input File: "))).read()
- simpen = str(input("[?] Output File: "))
- gas = bodo_amat(buka)
- gas.parserD()
- gas.parserK()
- gas.save(simpen)
- home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement