-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSSstache.py
117 lines (94 loc) · 3.86 KB
/
SSstache.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""Support Script stache"""
from plumbum import local
from plumbum.cmd import ls
from plumbum.path.utils import copy, delete
import os, shutil
def makeSupportScriptStache(stacheDir = 'VPsupportScripts',
GLOWPATH = '/Users/jonschull-MBPR/glowscript',
scriptNames ="""/lib/jquery/IDE/jquery.min.js
/lib/jquery/IDE/jquery-ui.custom.min.js
/package/glow.2.7.min.js
/package/RSrun.2.7.min.js
/css/redmond/jquery-ui.custom.css
/css/ide.css""".split() ):
""" Create folder called stacheDir
fill it with the scripts we named
by getting them from GLOWPATH (the directory where they can be found)
pytest
"""
verbose = False
SSS = os.getcwd() + '/' + stacheDir
if verbose: print('makeSupportScriptStache\t', SSS, end=' ')
try:
os.mkdir(SSS)
if verbose: print('created')
except FileExistsError:
if verbose: print('exists')
#scriptNames = '/lib/jquery/IDE/jquery.min.js /lib/jquery/IDE/jquery-ui.custom.min.js /package/glow.2.7.min.js /package/RSrun.2.7.min.js'.split()
#scriptNames = scriptNames + '/css/redmond/jquery-ui.custom.css /css/ide.css'.split()
for scriptName in scriptNames:
scriptPath = GLOWPATH + scriptName
scriptShortName = scriptName.split('/')[-1]
shutil.copyfile(scriptPath, SSS+'/'+scriptShortName)
return SSS
def prepareHTMLdir(dirName='test'):
"""create HTMLdir if necessary
pytest
"""
verbose=False
htmldir=os.getcwd() + '/' + dirName
if verbose: print('prepareHTMLdir\t', htmldir, end=' ')
try:
os.mkdir(dirName)
if verbose: print('created')
except FileExistsError:
if verbose: print('exists')
return htmldir
def out(s):
"""simple debug utility
if x==5, out(x) will print
=x= 5
"""
print(f'={s}= {globals()[s]}');
def makeHTMLdir(fileName,
stacheDir = 'VPsupportScripts',
GLOWPATH = '/Users/jonschull-MBPR/glowscript',
scriptNames ="""/lib/jquery/IDE/jquery.min.js
/lib/jquery/IDE/jquery-ui.custom.min.js
/package/glow.2.7.min.js
/package/RSrun.2.7.min.js
/css/redmond/jquery-ui.custom.css
/css/ide.css""".split() ):
"""create a stacheDir if necessary.
create HTMLdir
create supportScripts folder
fill it with scriptNames from stacheDir
pytest
"""
verbose=False
HTMLdir = fileName.replace('.py','')
if not os.path.exists(stacheDir):
makeSupportScriptStache(stacheDir, GLOWPATH, scriptNames)
prepareHTMLdir(HTMLdir)
#print(f'copy({fileName}, {HTMLdir})')
copy(fileName, HTMLdir)
destDir = HTMLdir + '/' + 'supportScripts'
delete(destDir)
if verbose: print('stacheDir', stacheDir)
#print('destDir', destDir)
copy(stacheDir,destDir)
if verbose: print('makeHTMLdir\t', destDir, 'created and filled')
return {'HTMLdir': HTMLdir, 'destDir': destDir}
def xxxputInHTMLdir(filename = 'test.py'):
""" create a directory for the python file
then put the pythonfile into it
"""
verbose=False
HTMLdir = filename.replace('.py','')
#newDir = makeHTMLdir(HTMLdir)
shutil.copyfile(filename, HTMLdir+'/'+ filename)
if verbose: print('putInHTMLdir\t', filename, 'copied into', HTMLdir)
if __name__=='__main__':
with open('boxtest.py','w') as f:
f.write('box()')
ret = makeHTMLdir('boxtest.py')