這工具本來是 PHP 版本的,不過由於接觸了 Python 關係
所以就用Python重寫了一次,實現的方法好像比較簡單.
而且這樣就不用每次也使用 IE, FireFox 來生成.呵呵.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
""" Author: Zeuxis Lo 傻心 - 窮等人家 P-Date: 2009-07-06 13:18 """
basePath = "template/eng" fileData = "<?php\nrequire_once 'include/init.php';\ninclude_once $tpl->display('%s');\n?>"
import os
fileList = os.listdir(basePath)
print "File List:\n==========="; for fileName in fileList: if fileName == "showmsg.html": continue; if os.path.isfile(basePath + "/" + fileName): print "File: " + fileName f = open(fileName.replace(".html", ".php"), "w+") f.write(fileData % fileName) f.close()
|