Commit 6f8a0c6e authored by frankie's avatar frankie 💬

better path management and comment in package.py

parent 2c7f0e22
......@@ -18,7 +18,6 @@ import uuid
import subprocess
import ftplib
'''
CONFIGURATION
'''
......@@ -180,7 +179,8 @@ def uglify( path ):
subprocess.call(["uglifyjs", path, "--compress", "--ie8", "--output", path ])
# cleaning the output path
for root, dirs, files in os.walk( export_folder+"/" ):
print( "cleaning up destination folder '" + export_folder + "'" )
for root, dirs, files in os.walk( export_folder ):
for f in files:
os.unlink(os.path.join( root, f ))
for d in dirs:
......@@ -188,20 +188,24 @@ for root, dirs, files in os.walk( export_folder+"/" ):
# copying all dirs
for d in copy_dirs:
copy( d, export_folder + "/" + d )
newpath = os.path.join( export_folder, d )
print( "copying folder '" + newpath + "' in destination folder" )
copy( d, newpath )
# creation of directories in package folder
for d in create_dir:
newpath = export_folder + "/" + d
newpath = os.path.join( export_folder, d )
print( "creating folder '" + newpath + "'" )
if not os.path.exists(newpath):
os.makedirs(newpath)
# copying all files
for d in copy_files:
infife = d[0]
outfife = export_folder + "/" + d[0]
outfife = os.path.join( export_folder, d[0] )
if len( d ) == 2:
outfife = export_folder + "/" + d[1]
outfife = os.path.join( export_folder, d[1] )
print( "copying file '" + src + "'" )
with open(infife, 'rb') as src, open( outfife, 'wb') as dst:
copyfileobj_example(src, dst)
......@@ -209,14 +213,16 @@ for d in copy_files:
css_content = get_content( css_files, 'css' )
css_content = css_content.replace('../', '')
export_file_css = export_file_css.replace( "#", str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_css
export_path = os.path.join( export_folder, export_file_css )
print( "creating css '" + export_path + "'" )
with open( export_path, 'w') as f:
f.write( css_content )
f.close()
# generation of common files, JS
threejs_content = get_content( threejs_files, 'js' )
export_path = export_folder+'/'+export_file_threejs
export_path = os.path.join( export_folder, export_file_threejs )
print( "creating javascript '" + export_path + "'" )
with open( export_folder+'/'+export_file_threejs , 'w') as f:
f.write( threejs_content )
f.close()
......@@ -231,7 +237,8 @@ for ef in export_files:
customjs_content = customjs_content.replace( pair[0], pair[1] )
export_file_customjs = ef['js_dst'].replace( '#', str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_customjs
export_path = os.path.join( export_folder, export_file_customjs )
print( "creating javascript '" + export_path + "'" )
with open( export_path, 'w') as f:
f.write( customjs_content )
f.close()
......@@ -240,9 +247,9 @@ for ef in export_files:
template_content = open( ef['html_tmpl'], 'r').read()
template_content = template_content.replace('<!--INCLUDE_CSS-->', '<link rel="stylesheet" href="'+export_file_css+'"/>')
template_content = template_content.replace('<!--INCLUDE_JS-->', '<script src="'+export_file_threejs+'"></script><script src="'+export_file_customjs+'"></script>')
with open( export_folder+'/'+ef['html_dst'] , 'w') as f:
print( "creating html '" + export_folder+'/'+ef['html_dst'] + "'" )
with open( os.path.join( export_folder, ef['html_dst'] ) , 'w') as f:
f.write( template_content )
f.close()
print( )
\ No newline at end of file
print( 'packaging successfull' )
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment