From e148e0acc9db6213a15b679e4c5c6aade7bbb54b Mon Sep 17 00:00:00 2001 From: Camille GOUTTEBROZE Date: Thu, 11 Sep 2014 16:22:20 +0200 Subject: [PATCH] Comments --- bin/profile-quickstart.py | 44 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/bin/profile-quickstart.py b/bin/profile-quickstart.py index ff7a19b6f..dce0224bb 100755 --- a/bin/profile-quickstart.py +++ b/bin/profile-quickstart.py @@ -23,22 +23,8 @@ import os import shutil import optparse -def generate_sources( options, args ): - - source_dir = os.path.join( options.prefix, options.name ) - - if os.path.exists( source_dir ) and not options.force : - print "Directory %s already exsits." %source_dir - print "Use option --force to overwrite it." - return - else : - if os.path.exists( source_dir ) : - shutil.rmtree( source_dir ) - os.makedirs( source_dir ) - -# ----------------------------------------------------------------------------- - -if __name__ == '__main__': +# Options of this script +def ProfileQuickStartParser() : parser = optparse.OptionParser( usage = "usage: python app-quickstart.py [options]" ) @@ -74,6 +60,30 @@ if __name__ == '__main__': dest="force", help="Overwrites existing sources") - (options, args) = parser.parse_args() + return parser + + +#Generation of a template profile sources +def generate_sources( options, args ) : + + #Name of the profile sources + source_dir = os.path.join( options.prefix, options.name ) + + #Check if the directory of the sources already exists + if os.path.exists( source_dir ) and not options.force : + print "Directory %s already exsits." %source_dir + print "Use option --force to overwrite it." + return + + # Create directory + if os.path.exists( source_dir ) : + shutil.rmtree( source_dir ) + os.makedirs( source_dir ) + +# ----------------------------------------------------------------------------- + +if __name__ == '__main__': + + (options, args) = ProfileQuickStartParser().parse_args() generate_sources( options, args ) -- 2.39.2