Salome HOME
bug fix
[tools/sat.git] / commands / environ.py
index c092916324b03192788223d60f9effbab7bc44d6..a552fddf0aa609d77e637f08ee8dc23fa23a4e49 100644 (file)
@@ -22,14 +22,15 @@ import src
 
 parser = src.options.Options()
 parser.add_option('', 'shell', 'list2', 'shell',
-    _("Generates the environment files for the given format: "
+    _("Optional: Generates the environment files for the given format: "
       "bash (default), bat (for windows) or all."), [])
 parser.add_option('p', 'products', 'list2', 'products',
-    _("Includes only the specified products."))
+    _("Optional: Includes only the specified products."))
 parser.add_option('', 'prefix', 'string', 'prefix',
-    _("Specifies the prefix for the environment files."), "env")
+    _("Optional: Specifies the prefix for the environment files."), "env")
 parser.add_option('t', 'target', 'string', 'out_dir',
-    _("Specifies the directory path where to put the environment files."), 
+    _("Optional: Specifies the directory path where to put the environment "
+      "files."),
     None)
 
 # list of available shells with extensions
@@ -39,9 +40,29 @@ C_ALL_SHELL = [ "bash", "bat" ]
 
 ##
 # Writes all the environment files
-def write_all_source_files(config, logger, out_dir=None, src_root=None,
-                           silent=False, shells=["bash"], prefix="env", env_info=None):
+def write_all_source_files(config,
+                           logger,
+                           out_dir=None,
+                           src_root=None,
+                           silent=False,
+                           shells=["bash"],
+                           prefix="env",
+                           env_info=None):
+    '''Generates the environment files.
     
+    :param config Config: The global configuration
+    :param logger Logger: The logger instance to use for the display 
+                          and logging
+    :param out_dir str: The path to the directory where the files will be put
+    :param src_root str: The path to the directory where the sources are
+    :param silent boolean: If True, do not print anything in the terminal
+    :param shells list: The list of shells to generate
+    :param prefix str: The prefix to add to the file names.
+    :param env_info str: The list of products to add in the files.
+    :return: The list of the generated files.
+    :rtype: List
+    '''
+        
     if not out_dir:
         out_dir = config.APPLICATION.workdir
 
@@ -49,8 +70,11 @@ def write_all_source_files(config, logger, out_dir=None, src_root=None,
         raise src.SatException(_("Target directory not found: %s") % out_dir)
 
     if not silent:
-        logger.write(_("Creating environment files for %s\n") % src.printcolors.printcLabel(config.APPLICATION.name), 2)
-        src.printcolors.print_value(logger, _("Target"), src.printcolors.printcInfo(out_dir), 3)
+        logger.write(_("Creating environment files for %s\n") % 
+                     src.printcolors.printcLabel(config.APPLICATION.name), 2)
+        src.printcolors.print_value(logger,
+                                    _("Target"),
+                                    src.printcolors.printcInfo(out_dir), 3)
         logger.write("\n", 3, False)
     
     shells_list = []
@@ -66,14 +90,24 @@ def write_all_source_files(config, logger, out_dir=None, src_root=None,
         else:
             shells_list.append(src.environment.Shell(shell, C_SHELLS[shell]))
     
-    writer = src.environment.FileEnvWriter(config, logger, out_dir, src_root, env_info)
+    writer = src.environment.FileEnvWriter(config,
+                                           logger,
+                                           out_dir,
+                                           src_root,
+                                           env_info)
     writer.silent = silent
     files = []
     for_build = True
     for_launch = False
     for shell in shells_list:
-        files.append(writer.write_env_file("%s_launch.%s" % (prefix, shell.extension), for_launch, shell.name))
-        files.append(writer.write_env_file("%s_build.%s" % (prefix, shell.extension),  for_build,  shell.name))
+        files.append(writer.write_env_file("%s_launch.%s" %
+                                           (prefix, shell.extension),
+                                           for_launch,
+                                           shell.name))
+        files.append(writer.write_env_file("%s_build.%s" %
+                                           (prefix, shell.extension),
+                                           for_build,
+                                           shell.name))
 
     return files
 
@@ -82,8 +116,8 @@ def write_all_source_files(config, logger, out_dir=None, src_root=None,
 ##
 # Describes the command
 def description():
-    return _("The environ command generates the "
-                "environment files of your application.")
+    return _("The environ command generates the environment files of your "
+             "application.\n\nexample:\nsat environ SALOME-master")
 
 ##
 # Runs the command.
@@ -96,8 +130,11 @@ def run(args, runner, logger):
     if options.products is None:
         environ_info = None
     else:
-        # add products specified by user (only products included in the application)
-        environ_info = filter(lambda l: l in runner.cfg.APPLICATION.products.keys(), options.products)
+        # add products specified by user (only products 
+        # included in the application)
+        environ_info = filter(lambda l:
+                              l in runner.cfg.APPLICATION.products.keys(),
+                              options.products)
     
     if options.shell == []:
         shell = ["bash"]