From 9bbc3a7c7b03a47fec2a1a7947a0a2804765d8e9 Mon Sep 17 00:00:00 2001 From: Camille GOUTTEBROZE Date: Tue, 30 Sep 2014 14:13:52 +0200 Subject: [PATCH] More clever way to copy bin/app-template --- bin/app-quickstart.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/bin/app-quickstart.py b/bin/app-quickstart.py index 180d81fb2..8185a4b4c 100755 --- a/bin/app-quickstart.py +++ b/bin/app-quickstart.py @@ -78,33 +78,33 @@ def profileGenerateSources( options, args ) : #Set name of several directories app_dir = os.path.join( options.prefix, options.name ) - src_dir = os.path.join( app_dir, "src" ) - kernek_root_dir = os.environ["KERNEL_ROOT_DIR"] - bin_dir = os.path.join( kernek_root_dir, "bin", "salome" ) - template_dir = os.path.join( bin_dir, "app-template" ) + kernel_root_dir = os.environ["KERNEL_ROOT_DIR"] + bin_salome_dir = os.path.join( kernel_root_dir, "bin", "salome" ) + template_dir = os.path.join( bin_salome_dir, "app-template" ) - #Check if the directory of the sources already exists - if os.path.exists( app_dir ) and not options.force : - print "Directory %s already exists." %app_dir - print "Use option --force to overwrite it." - return + #Check if the directory of the sources already exists and delete it + if os.path.exists( app_dir ) : + if not options.force : + print "Directory %s already exists." %app_dir + print "Use option --force to overwrite it." + return + else : + shutil.rmtree( app_dir ) #Copy template directory - if os.path.exists( app_dir ) : - shutil.rmtree( app_dir ) - shutil.copytree( template_dir, app_dir ) + os.mkdir( app_dir ) + for root, dirs, files in os.walk( template_dir ) : + dst_dir = root.replace( template_dir, app_dir ) + for d in dirs : + os.mkdir( os.path.join( dst_dir, d ) ) + for f in files : + profileReplaceStrings( os.path.join( root, f ), os.path.join( dst_dir, f ), options ) #Complete source directory contextFiles = [ "salomeContext.py", "salomeContextUtils.py", "parseConfigFile.py" ] for f in contextFiles : - shutil.copy( os.path.join( bin_dir, f ), src_dir ) - - #Adapt source directory - profileReplaceStrings( os.path.join( template_dir, "resources", "SalomeApp.xml.in" ), os.path.join( os.path.join( app_dir, "resources" ), "SalomeApp.xml.in" ), options ) - profileReplaceStrings( os.path.join( template_dir, "resources", "CMakeLists.txt" ), os.path.join( os.path.join( app_dir, "resources" ), "CMakeLists.txt" ), options ) - profileReplaceStrings( os.path.join( template_dir, "CMakeLists.txt" ), os.path.join( app_dir, "CMakeLists.txt" ), options ) - profileReplaceStrings( os.path.join( template_dir, "doc", "index.rst" ), os.path.join( os.path.join( app_dir, "doc" ), "index.rst" ), options ) - profileReplaceStrings( os.path.join( template_dir, "doc", "conf.py.in" ), os.path.join( os.path.join( app_dir, "doc" ), "conf.py.in" ), options ) + shutil.copy( os.path.join( bin_salome_dir, f ), os.path.join( app_dir, "src" ) ) + # ----------------------------------------------------------------------------- -- 2.39.2