Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import os
- import string
- if(len(sys.argv) < 2):
- print ("Adj meg egy file-t!")
- exit()
- if (not os.path.isfile(sys.argv[1])):
- print ("Nincs ilyen file!")
- exit()
- a=list()
- b=list()
- fajlnev = sys.argv[1]
- with open(fajl) as lines:
- for line in lines.readlines():
- aktual = line.split(' ')
- if aktual[0]=="#::":
- a.append(aktual[1])
- if aktual[0]=="#::":
- b.append(aktual[2][:-1])
- dictionary = dict(zip(a, b))
- filename = sys.argv[1].split(".")
- outfile=filename[0]+"_out.py"
- def switch(text, dic):
- for i, j in dic.iteritems():
- text = text.replace(i, j)
- return text
- kiiras = open(outfile,'w')
- with open(fajlnev) as lines:
- for line in lines.readlines()[len(a):]:
- kiiras.write(switch(line, dictionary))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement