57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
|
import os.path
|
|||
|
import re
|
|||
|
|
|||
|
import utils
|
|||
|
|
|||
|
|
|||
|
def test_copy(source, dest: str):
|
|||
|
sourceFiles = utils.listFiles(source, 'lua')
|
|||
|
for i in sourceFiles:
|
|||
|
print(i)
|
|||
|
content = utils.load_file(filename=i, encode='utf-8')
|
|||
|
# 创建文件
|
|||
|
filename = i.replace(source, dest)
|
|||
|
utils.file_exist(filename)
|
|||
|
with open(file=filename, mode="w", encoding='utf-8') as f:
|
|||
|
f.write(content)
|
|||
|
f.close()
|
|||
|
|
|||
|
|
|||
|
# 将代码中所有的 :fun 替换成 fun
|
|||
|
def test_remove_simple(source: str):
|
|||
|
sourceFiles = utils.listFiles(source, 'lua')
|
|||
|
for i in sourceFiles:
|
|||
|
with open(i, mode='r', encoding='utf-8') as f:
|
|||
|
content: str = f.read()
|
|||
|
f.close()
|
|||
|
# 检查前面是否含有 (:
|
|||
|
arr = content.split('\n')
|
|||
|
conts = []
|
|||
|
for c in arr:
|
|||
|
conts.append(utils.replace_first_occurrence(c, ':fun(', ' fun('))
|
|||
|
content = '\n'.join(conts)
|
|||
|
with open(i, mode='w', encoding='utf-8') as f:
|
|||
|
f.write(content)
|
|||
|
f.close()
|
|||
|
|
|||
|
|
|||
|
def test2(foldername: str = None):
|
|||
|
if foldername is None:
|
|||
|
foldername = '..\\'
|
|||
|
else:
|
|||
|
foldername = '..\\' + foldername + '\\Script'
|
|||
|
utils.add_type(foldername)
|
|||
|
|
|||
|
|
|||
|
def test1():
|
|||
|
test_remove_simple(r'..\..\Content\LuaHelper')
|
|||
|
|
|||
|
|
|||
|
if __name__ == '__main__':
|
|||
|
# test_copy('ProjectTemp', 'Test_Island')
|
|||
|
# os.system("rmdir.bat")
|
|||
|
# test2('AthleticMasters')
|
|||
|
test1()
|
|||
|
# utils.removeFiles('..\\Saved\\Logs\\Test_Island')
|
|||
|
pass
|