forked from amarsahinovic/django-zurb-foundation
-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy_statics.py
73 lines (58 loc) · 1.65 KB
/
copy_statics.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding:utf-8 -*-
"""
Created on Jan 1, 2016
@author: Wasim
"""
import errno
import glob
import os
import shutil
def main():
zf = r'zurb-foundation-sites/'
df = r'foundation/static/foundation/'
zm = r'zurb-motion-ui/'
dm = r'foundation/static/motion-ui/'
pathes = (
(glob.glob(zf + 'scss'), df + 'scss'),
(glob.glob(zf + '_vendor'), df + '_vendor'),
(glob.glob(zf + 'js'), df + 'js.es6'),
(glob.glob(zf + 'dist/css'), df + 'css'),
(glob.glob(zf + 'dist/js'), df + 'js'),
(zf + 'LICENSE', df),
(glob.glob(zm + 'src'), dm + 'scss'),
(glob.glob(zm + 'dist/*.css'), dm + 'css', True),
(glob.glob(zm + 'dist/*.js'), dm + 'js', True),
(zm + 'LICENSE', dm),
)
for row in pathes:
src, dst, mkdir = (row + (False,))[0:3]
print('copy %s to %s' % (src, dst))
if isinstance(src, list):
try:
shutil.rmtree(dst)
except OSError as e:
if e.errno not in (errno.ENOENT, errno.EINVAL):
raise
if mkdir:
try:
os.makedirs(dst)
except OSError:
pass
for s in src:
cp(s, dst)
else:
try:
os.makedirs(dst)
except OSError:
pass
shutil.copy(src, dst)
def cp(src, dst):
try:
shutil.copytree(src, dst)
except OSError as exc:
if exc.errno in (errno.ENOTDIR, errno.EINVAL):
shutil.copy(src, dst)
else:
raise
if __name__ == '__main__':
main()