forked from MineClone5/MineClone5
added tool to fix all space/tab issues
This commit is contained in:
parent
25ff05635a
commit
57946e8429
|
@ -0,0 +1,49 @@
|
||||||
|
#ONLY RUN FROM THE MCL5 TOOLS FOLDER!
|
||||||
|
|
||||||
|
|
||||||
|
__author__ = "chmodsayshello"
|
||||||
|
__license__ = "GPLv3"
|
||||||
|
__status__ = "Development"
|
||||||
|
|
||||||
|
#the ironic thing about this file is that i am going to made many many space /tab mistakes here xD
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
|
||||||
|
mcl5_dir = os.path.join(os.getcwd(), os.pardir)
|
||||||
|
|
||||||
|
print("Semi Warning: this only works if you run this from <yourmcl5foler>/tools, else its going to do it from any folder above from where you run it, just answer with 2 if thats the case")
|
||||||
|
print("")
|
||||||
|
print("WARNING: THIS IS GOING TO MAKE CHANGES WITHOUT ASKING YOU, MAKE A COPY OF YOUR CODE BEFORE RUNNING THIS!")
|
||||||
|
print("1: Continue")
|
||||||
|
print("2: Cancel")
|
||||||
|
print("")
|
||||||
|
answer = input("Please Enter 1 or 2, anthing else is invalid: ")
|
||||||
|
|
||||||
|
if answer == "1":
|
||||||
|
print("Thanks for your permission :), starting...")
|
||||||
|
else:
|
||||||
|
if answer == "2":
|
||||||
|
sys.exit("Operation cancelled by user!")
|
||||||
|
else:
|
||||||
|
sys.exit("Invalid input")
|
||||||
|
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(mcl5_dir):
|
||||||
|
for name in files:
|
||||||
|
if name.endswith(".lua"):
|
||||||
|
mod = open(os.path.join(root, name),"r+")
|
||||||
|
|
||||||
|
for line in mod:
|
||||||
|
line_original = mod.readline()
|
||||||
|
line_correct = line.replace(" ", " ") #4 spaces into one tab
|
||||||
|
codelist = []
|
||||||
|
|
||||||
|
if line_correct != line_original:
|
||||||
|
codelist.append("\n"+line_correct)
|
||||||
|
else:
|
||||||
|
codelist.append("\n"+line_original)
|
||||||
|
|
||||||
|
del codelist[-1] #the last line is there twice, deleting it one...
|
||||||
|
mod.writelines(codelist)
|
||||||
|
mod.close()
|
||||||
|
print("DONE! check if mcl5 still works!")
|
Loading…
Reference in New Issue