-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreate_site.py
84 lines (73 loc) · 2.36 KB
/
create_site.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
74
75
76
77
78
79
80
81
82
83
84
# This script obtains all that is needed from blockly to have the site with
# Blockly for Arduino
import sys
import os
import shutil
root_dir = 'Blockly4Arduino'
if os.path.isdir(root_dir):
shutil.rmtree(root_dir)
os.mkdir(root_dir, 0775)
orig_dir = "../ardublockly/blockly"
dirs = ['blocks',
'blocks/arduino',
'core',
'blockly4Arduino',
'blockly4Arduino/examples',
'blockly4Arduino/examples/AllBot',
'blockly4Arduino/examples/TFT',
'blockly4Arduino/js_libs',
'blockly4Arduino/materialize',
'blockly4Arduino/msg',
'blockly4Arduino/prettify',
'blockly4Arduino/font',
'blockly4Arduino/font/droid',
'blockly4Arduino/font/material-design-icons',
'blockly4Arduino/font/roboto',
'generators/arduino',
'libs',
'libs/bootstrap',
'libs/bootstrap/css',
'libs/bootstrap/fonts',
'libs/bootstrap/js',
'libs/jquery',
'media',
'media/arduino',
'media/mark',
'media/MD',
'msg',
'msg/js',
]
files = ['arduino_compressed.js',
'blockly_compressed.js',
'blockly_uncompressed.js',
'blocks_compressed.js',
'LICENSE',
'package.json',
'generators/arduino.js',
'index.html',
'index_en.html'
]
app = ['blockly4Arduino/index.html']
for dirname in dirs:
parts = dirname.split('/')
for ind, part in enumerate(parts):
dirpath = part
if ind>0:
dirpath = os.path.join(*parts[:ind+1])
if not os.path.isdir(root_dir+os.sep+dirpath):
os.mkdir(root_dir+os.sep+dirpath, 0775)
if ind+1 == len(parts):
names = os.listdir(orig_dir+os.sep+dirpath)
for name in names:
srcname = os.path.join(orig_dir+os.sep+dirpath, name)
dstname = os.path.join(root_dir+os.sep+dirpath, name)
if not os.path.isdir(srcname):
shutil.copy(srcname, dstname)
for filename in files:
parts = filename.split('/')
if len(parts)==1:
shutil.copy(orig_dir + os.sep + filename, root_dir)
else:
shutil.copy(orig_dir + os.sep + os.path.join(*parts[:len(parts)-1])
+ os.sep + parts[-1],
root_dir + os.sep + os.path.join(*parts[:len(parts)-1]))