forked from zeasin/qihangerp-scm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
28 lines (19 loc) · 945 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import time
# 复制文件
def copyFiles(sourceDir, targetDir):
# 将模版里的样式文件拷贝到网站目录
for f in os.listdir(sourceDir):
sourceF = os.path.join(sourceDir, f)
targetF = os.path.join(targetDir, f)
print("文件名:%s" % sourceF)
if os.path.isfile(sourceF) and f != ".DS_Store" and f.find('.html') < 0:
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetF) or (
os.path.exists(targetF) and (os.path.getsize(targetF) != os.path.getsize(sourceF))):
# 2进制文件 * l$ _ o- b2 ~" a
open(targetF, "wb").write(open(sourceF, "rb").read())
print(u"%s %s 复制完毕" % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), targetF))
if os.path.isdir(sourceF):
copyFiles(sourceF, targetF)