Salome HOME
Merge branch 'master' of /home/salome/GitRepo/salomeTools-5
[tools/sat.git] / src / product.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 '''In this file are implemented the methods 
19    relative to the product notion of salomeTools
20 '''
21
22 import os
23 import re
24
25 import src
26
27 AVAILABLE_VCS = ['git', 'svn', 'cvs']
28 config_expression = "^config-\d+$"
29 VERSION_DELIMITER = "_to_"
30
31 def get_product_config(config, product_name, with_install_dir=True):
32     '''Get the specific configuration of a product from the global configuration
33     
34     :param config Config: The global configuration
35     :param product_name str: The name of the product
36     :param with_install_dir boolean: If false, do not provide an install 
37                                      directory (at false only for internal use 
38                                      of the function check_config_exists)
39     :return: the specific configuration of the product
40     :rtype: Config
41     '''
42     
43     # Get the version of the product from the application definition
44     version = config.APPLICATION.products[product_name]
45     # if no version, then take the default one defined in the application
46     if isinstance(version, bool): 
47         version = config.APPLICATION.tag      
48     
49     # Define debug and dev modes
50     # Get the tag if a dictionary is given in APPLICATION.products for the
51     # current product 
52     debug = 'no'
53     dev = 'no'
54     base = 'maybe'
55     section = None
56     if isinstance(version, src.pyconf.Mapping):
57         dic_version = version
58         # Get the version/tag
59         if not 'tag' in dic_version:
60             version = config.APPLICATION.tag
61         else:
62             version = dic_version.tag
63         
64         # Get the debug if any
65         if 'debug' in dic_version:
66             debug = dic_version.debug
67         
68         # Get the dev if any
69         if 'dev' in dic_version:
70             dev = dic_version.dev
71         
72         # Get the base if any
73         if 'base' in dic_version:
74             base = dic_version.base
75
76         # Get the section if any
77         if 'section' in dic_version:
78             section = dic_version.section
79     
80     vv = version
81     # substitute some character with _ in order to get the correct definition
82     # in config.PRODUCTS. This is done because the pyconf tool does not handle
83     # the . and - characters 
84     for c in ".-": vv = vv.replace(c, "_")
85     
86     prod_info = None
87     if product_name in config.PRODUCTS:
88         # Search for the product description in the configuration
89         prod_info = get_product_section(config, product_name, vv, section)
90         
91         # merge opt_depend in depend
92         if prod_info is not None and 'opt_depend' in prod_info:
93             for depend in prod_info.opt_depend:
94                 if depend in config.APPLICATION.products:
95                     prod_info.depend.append(depend,'')
96         
97         # In case of a product get with a vcs, 
98         # put the tag (equal to the version)
99         if prod_info is not None and prod_info.get_source in AVAILABLE_VCS:
100             
101             if prod_info.get_source == 'git':
102                 prod_info.git_info.tag = version
103             
104             if prod_info.get_source == 'svn':
105                 prod_info.svn_info.tag = version
106             
107             if prod_info.get_source == 'cvs':
108                 prod_info.cvs_info.tag = version
109         
110         # In case of a fixed product, 
111         # define the install_dir (equal to the version)
112         if prod_info is not None and os.path.isdir(version):
113             prod_info.install_dir = version
114             prod_info.get_source = "fixed"
115         
116         # Check if the product is defined as native in the application
117         if prod_info is not None:
118             if version == "native":
119                 prod_info.get_source = "native"
120             elif prod_info.get_source == "native":
121                 msg = _("The product %(prod)s has version %(ver)s but is "
122                         "declared as native in its definition" %
123                         { 'prod': prod_info.name, 'ver': version})
124                 raise src.SatException(msg)
125
126     # If there is no definition but the product is declared as native,
127     # construct a new definition containing only the get_source key
128     if prod_info is None and version == "native":
129         prod_info = src.pyconf.Config()
130         prod_info.name = product_name
131         prod_info.get_source = "native"
132
133     # If there is no definition but the product is fixed,
134     # construct a new definition containing only the product name
135     if prod_info is None and os.path.isdir(version):
136         prod_info = src.pyconf.Config()
137         prod_info.name = product_name
138         prod_info.get_source = "fixed"
139         prod_info.addMapping("environ", src.pyconf.Mapping(prod_info), "")
140
141
142     # If prod_info is still None, it means that there is no product definition
143     # in the config. The user has to provide it.
144     if prod_info is None:
145         prod_pyconf_path = src.find_file_in_lpath(product_name + ".pyconf",
146                                                   config.PATHS.PRODUCTPATH)
147         if not prod_pyconf_path:
148             msg = _("No definition found for the product %s\n"
149                "Please create a %s.pyconf file." % (product_name, product_name))
150         else:
151             msg = _("No definition corresponding to the version %(version)s was"
152                     " found in the file %(prod_file_path)s.\nPlease add a "
153                     "section in it." % {"version" : vv,
154                                         "prod_file_path" : prod_pyconf_path} )
155         raise src.SatException(msg)
156     
157     # Set the debug, dev and version keys
158     prod_info.debug = debug
159     prod_info.dev = dev
160     prod_info.version = version
161     
162     # Set the archive_info if the product is get in archive mode
163     if prod_info.get_source == "archive":
164         if not "archive_info" in prod_info:
165             prod_info.addMapping("archive_info",
166                                  src.pyconf.Mapping(prod_info),
167                                  "")
168         if "archive_name" not in prod_info.archive_info: 
169             arch_name = product_name + "-" + version + ".tar.gz"
170             arch_path = src.find_file_in_lpath(arch_name,
171                                                config.PATHS.ARCHIVEPATH)
172             if not arch_path:
173                 msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
174                             "\n" % {"arch_name" : arch_name,
175                                      "prod_name" : prod_info.name}) 
176                 raise src.SatException(msg)
177             prod_info.archive_info.archive_name = arch_path
178         else:
179             if (os.path.basename(prod_info.archive_info.archive_name) == 
180                                         prod_info.archive_info.archive_name):
181                 arch_name = prod_info.archive_info.archive_name
182                 arch_path = src.find_file_in_lpath(
183                                             arch_name,
184                                             config.PATHS.ARCHIVEPATH)
185                 if not arch_path:
186                     msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
187                                 "\n" % {"arch_name" : arch_name,
188                                          "prod_name" : prod_info.name}) 
189                     raise src.SatException(msg)
190                 prod_info.archive_info.archive_name = arch_path
191         
192     # If the product compiles with a script, check the script existence
193     # and if it is executable
194     if product_has_script(prod_info):
195         # Check the compil_script key existence
196         if "compil_script" not in prod_info:
197             msg = _("No compilation script found for the product %s\n"
198                 "Please provide a \"compil_script\" key in its definition." 
199                 % (product_name))
200             raise src.SatException(msg)
201         
202         # Get the path of the script
203         script = prod_info.compil_script
204         script_name = os.path.basename(script)
205         if script == script_name:
206             # Only a name is given. Search in the default directory
207             script_path = src.find_file_in_lpath(script_name,
208                                                  config.PATHS.PRODUCTPATH,
209                                                  "compil_scripts")
210             if not script_path:
211                 raise src.SatException(_("Compilation script not found: %s") % 
212                                    script_name)
213             prod_info.compil_script = script_path
214        
215         # Check that the script is executable
216         if not os.access(prod_info.compil_script, os.X_OK):
217             raise src.SatException(
218                     _("Compilation script cannot be executed: %s") % 
219                     prod_info.compil_script)
220     
221     # Get the full paths of all the patches
222     if product_has_patches(prod_info):
223         patches = []
224         for patch in prod_info.patches:
225             patch_path = patch
226             # If only a filename, then search for the patch in the PRODUCTPATH
227             if os.path.basename(patch_path) == patch_path:
228                 # Search in the PRODUCTPATH/patches
229                 patch_path = src.find_file_in_lpath(patch,
230                                                     config.PATHS.PRODUCTPATH,
231                                                     "patches")
232                 if not patch_path:
233                     msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
234                             "\n" % {"patch_name" : patch,
235                                      "prod_name" : prod_info.name}) 
236                     raise src.SatException(msg)
237             patches.append(patch_path)
238         prod_info.patches = patches
239
240     # Get the full paths of the environment scripts
241     if product_has_env_script(prod_info):
242         env_script_path = prod_info.environ.env_script
243         # If only a filename, then search for the environment script 
244         # in the PRODUCTPATH/env_scripts
245         if os.path.basename(env_script_path) == env_script_path:
246             # Search in the PRODUCTPATH/env_scripts
247             env_script_path = src.find_file_in_lpath(
248                                             prod_info.environ.env_script,
249                                             config.PATHS.PRODUCTPATH,
250                                             "env_scripts")
251             if not env_script_path:
252                 msg = _("Environment script %(env_name)s for %(prod_name)s not "
253                         "found.\n" % {"env_name" : env_script_path,
254                                        "prod_name" : prod_info.name}) 
255                 raise src.SatException(msg)
256
257         prod_info.environ.env_script = env_script_path
258     
259     if with_install_dir: 
260         # The variable with_install_dir is at false only for internal use 
261         # of the function get_install_dir
262         
263         # Set the install_dir key
264         prod_info.install_dir = get_install_dir(config, base, version, prod_info)
265                 
266     return prod_info
267
268 def get_product_section(config, product_name, version, section=None):
269     '''Get the product description from the configuration
270     
271     :param config Config: The global configuration
272     :param product_name str: The product name
273     :param version str: The version of the product
274     :param section str: The searched section (if not None, the section is 
275                         explicitly given
276     :return: The product description
277     :rtype: Config
278     '''
279
280     # if section is not None, try to get the corresponding section
281     if section:
282         if section not in config.PRODUCTS[product_name]:
283             return None
284         # returns specific information for the given version
285         prod_info = config.PRODUCTS[product_name][section]
286         prod_info.section = section
287         return prod_info
288
289     # If it exists, get the information of the product_version
290     if "version_" + version in config.PRODUCTS[product_name]:
291         # returns specific information for the given version
292         prod_info = config.PRODUCTS[product_name]["version_" + version]
293         prod_info.section = "version_" + version
294         return prod_info
295     
296     # Else, check if there is a description for multiple versions
297     l_section_name = config.PRODUCTS[product_name].keys()
298     l_section_ranges = [section_name for section_name in l_section_name 
299                         if VERSION_DELIMITER in section_name]
300     for section_range in l_section_ranges:
301         minimum, maximum = section_range.split(VERSION_DELIMITER)
302         if (src.only_numbers(version) >= src.only_numbers(minimum)
303                     and src.only_numbers(version) <= src.only_numbers(maximum)):
304             # returns specific information for the versions
305             prod_info = config.PRODUCTS[product_name][section_range]
306             prod_info.section = section_range
307             return prod_info
308     
309     # Else, get the standard informations
310     if "default" in config.PRODUCTS[product_name]:
311         # returns the generic information (given version not found)
312         prod_info = config.PRODUCTS[product_name].default
313         prod_info.section = "default"
314         return prod_info
315     
316     # if noting was found, return None
317     return None
318     
319 def get_install_dir(config, base, version, prod_info):
320     '''Compute the installation directory of a given product 
321     
322     :param config Config: The global configuration
323     :param base str: This corresponds to the value given by user in its 
324                      application.pyconf for the specific product. If "yes", the
325                     user wants the product to be in base. If "no", he wants the
326                     product to be in the application workdir
327     :param version str: The version of the product
328     :param product_info Config: The configuration specific to 
329                                the product
330     
331     :return: The path of the product installation
332     :rtype: str
333     '''
334     install_dir = ""
335     in_base = False
336     if (("install_dir" in prod_info and prod_info.install_dir == "base") 
337                                                             or base == "yes"):
338         in_base = True
339     if (base == "no" or ("no_base" in config.APPLICATION 
340                          and config.APPLICATION.no_base == "yes")):
341         in_base = False
342     
343     if in_base:
344         install_dir = get_base_install_dir(config, prod_info, version)
345     else:
346         if "install_dir" not in prod_info or prod_info.install_dir == "base":
347             # Set it to the default value (in application directory)
348             install_dir = os.path.join(config.APPLICATION.workdir,
349                                                 "INSTALL",
350                                                 prod_info.name)
351         else:
352             install_dir = prod_info.install_dir
353
354     return install_dir
355
356 def get_base_install_dir(config, prod_info, version):
357     '''Compute the installation directory of a product in base 
358     
359     :param config Config: The global configuration
360     :param product_info Config: The configuration specific to 
361                                the product
362     :param version str: The version of the product    
363     :return: The path of the product installation
364     :rtype: str
365     '''    
366     base_path = src.get_base_path(config) 
367     prod_dir = os.path.join(base_path, prod_info.name + "-" + version)
368     if not os.path.exists(prod_dir):
369         return os.path.join(prod_dir, "config-1")
370     
371     exists, install_dir = check_config_exists(config, prod_dir, prod_info)
372     if exists:
373         return install_dir
374     
375     # Find the first config-<i> directory that is available in the product
376     # directory
377     found = False 
378     label = 1
379     while not found:
380         install_dir = os.path.join(prod_dir, "config-%i" % label)
381         if os.path.exists(install_dir):
382             label+=1
383         else:
384             found = True
385             
386     return install_dir
387
388 def check_config_exists(config, prod_dir, prod_info):
389     '''Verify that the installation directory of a product in a base exists
390        Check all the config-<i> directory and verify the sat-config.pyconf file
391        that is in it 
392     
393     :param config Config: The global configuration
394     :param prod_dir str: The product installation directory path 
395                          (without config-<i>)
396     :param product_info Config: The configuration specific to 
397                                the product
398     :return: True or false is the installation is found or not 
399              and if it is found, the path of the found installation
400     :rtype: (boolean, str)
401     '''   
402     # check if the directories or files of the directory corresponds to the 
403     # directory installation of the product
404     l_dir_and_files = os.listdir(prod_dir)
405     for dir_or_file in l_dir_and_files:
406         oExpr = re.compile(config_expression)
407         if not(oExpr.search(dir_or_file)):
408             # not config-<i>, not interesting
409             continue
410         # check if there is the file sat-config.pyconf file in the installation
411         # directory    
412         config_file = os.path.join(prod_dir, dir_or_file, src.CONFIG_FILENAME)
413         if not os.path.exists(config_file):
414             continue
415         
416         # If there is no dependency, it is the right path
417         if len(prod_info.depend)==0:
418             compile_cfg = src.pyconf.Config(config_file)
419             if len(compile_cfg) == 0:
420                 return True, os.path.join(prod_dir, dir_or_file)
421             continue
422         
423         # check if there is the config described in the file corresponds the 
424         # dependencies of the product
425         config_corresponds = True    
426         compile_cfg = src.pyconf.Config(config_file)
427         for prod_dep in prod_info.depend:
428             # if the dependency is not in the config, 
429             # the config does not correspond
430             if prod_dep not in compile_cfg:
431                 config_corresponds = False
432                 break
433             else:
434                 prod_dep_info = get_product_config(config, prod_dep, False)
435                 # If the version of the dependency does not correspond, 
436                 # the config does not correspond
437                 if prod_dep_info.version != compile_cfg[prod_dep]:
438                     config_corresponds = False
439                     break
440         
441         for prod_name in compile_cfg:
442             if prod_name not in prod_info.depend:
443                 config_corresponds = False
444                 break
445         
446         if config_corresponds:
447             return True, os.path.join(prod_dir, dir_or_file)
448     
449     return False, None
450             
451             
452     
453 def get_products_infos(lproducts, config):
454     '''Get the specific configuration of a list of products
455     
456     :param lproducts List: The list of product names
457     :param config Config: The global configuration
458     :return: the list of tuples 
459              (product name, specific configuration of the product)
460     :rtype: [(str, Config)]
461     '''
462     products_infos = []
463     # Loop on product names
464     for prod in lproducts:       
465         # Get the specific configuration of the product
466         prod_info = get_product_config(config, prod)
467         if prod_info is not None:
468             products_infos.append((prod, prod_info))
469         else:
470             msg = _("The %s product has no definition "
471                     "in the configuration.") % prod
472             raise src.SatException(msg)
473     return products_infos
474
475 def get_product_dependencies(config, product_info):
476     '''Get recursively the list of products that are 
477        in the product_info dependencies
478     
479     :param config Config: The global configuration
480     :param product_info Config: The configuration specific to 
481                                the product
482     :return: the list of products in dependence
483     :rtype: list
484     '''
485     if "depend" not in product_info or product_info.depend == []:
486         return []
487     res = []
488     for prod in product_info.depend:
489         if prod == product_info.name:
490             continue
491         if prod not in res:
492             res.append(prod)
493         prod_info = get_product_config(config, prod)
494         dep_prod = get_product_dependencies(config, prod_info)
495         for prod_in_dep in dep_prod:
496             if prod_in_dep not in res:
497                 res.append(prod_in_dep)
498     return res
499
500 def check_installation(product_info):
501     '''Verify if a product is well installed. Checks install directory presence
502        and some additional files if it is defined in the config 
503     
504     :param product_info Config: The configuration specific to 
505                                the product
506     :return: True if it is well installed
507     :rtype: boolean
508     '''
509     if not product_compiles(product_info):
510         return True
511     install_dir = product_info.install_dir
512     if not os.path.exists(install_dir):
513         return False
514     if ("present_files" in product_info and 
515         "install" in product_info.present_files):
516         for file_relative_path in product_info.present_files.install:
517             file_path = os.path.join(install_dir, file_relative_path)
518             if not os.path.exists(file_path):
519                 return False
520     return True
521
522 def product_is_sample(product_info):
523     '''Know if a product has the sample type
524     
525     :param product_info Config: The configuration specific to 
526                                the product
527     :return: True if the product has the sample type, else False
528     :rtype: boolean
529     '''
530     if 'type' in product_info:
531         ptype = product_info.type
532         return ptype.lower() == 'sample'
533     else:
534         return False
535
536 def product_is_salome(product_info):
537     '''Know if a product is of type salome
538     
539     :param product_info Config: The configuration specific to 
540                                the product
541     :return: True if the product is salome, else False
542     :rtype: boolean
543     '''
544     if 'type' in product_info:
545         ptype = product_info.type
546         return ptype.lower() == 'salome'
547     else:
548         return False
549
550 def product_is_fixed(product_info):
551     '''Know if a product is fixed
552     
553     :param product_info Config: The configuration specific to 
554                                the product
555     :return: True if the product is fixed, else False
556     :rtype: boolean
557     '''
558     get_src = product_info.get_source
559     return get_src.lower() == 'fixed'
560
561 def product_is_native(product_info):
562     '''Know if a product is native
563     
564     :param product_info Config: The configuration specific to 
565                                the product
566     :return: True if the product is native, else False
567     :rtype: boolean
568     '''
569     get_src = product_info.get_source
570     return get_src.lower() == 'native'
571
572 def product_is_dev(product_info):
573     '''Know if a product is in dev mode
574     
575     :param product_info Config: The configuration specific to 
576                                the product
577     :return: True if the product is in dev mode, else False
578     :rtype: boolean
579     '''
580     dev = product_info.dev
581     return dev.lower() == 'yes'
582
583 def product_is_debug(product_info):
584     '''Know if a product is in debug mode
585     
586     :param product_info Config: The configuration specific to 
587                                the product
588     :return: True if the product is in debug mode, else False
589     :rtype: boolean
590     '''
591     debug = product_info.debug
592     return debug.lower() == 'yes'
593
594 def product_is_autotools(product_info):
595     '''Know if a product is compiled using the autotools
596     
597     :param product_info Config: The configuration specific to 
598                                the product
599     :return: True if the product is autotools, else False
600     :rtype: boolean
601     '''
602     build_src = product_info.build_source
603     return build_src.lower() == 'autotools'
604
605 def product_is_cmake(product_info):
606     '''Know if a product is compiled using the cmake
607     
608     :param product_info Config: The configuration specific to 
609                                the product
610     :return: True if the product is cmake, else False
611     :rtype: boolean
612     '''
613     build_src = product_info.build_source
614     return build_src.lower() == 'cmake'
615
616 def product_is_vcs(product_info):
617     '''Know if a product is download using git, svn or cvs (not archive)
618     
619     :param product_info Config: The configuration specific to 
620                                the product
621     :return: True if the product is vcs, else False
622     :rtype: boolean
623     '''
624     return product_info.get_source in AVAILABLE_VCS
625
626 def product_is_SALOME(product_info):
627     '''Know if a product is a SALOME module
628     
629     :param product_info Config: The configuration specific to 
630                                the product
631     :return: True if the product is a SALOME module, else False
632     :rtype: boolean
633     '''
634     return ("properties" in product_info and
635             "is_SALOME_module" in product_info.properties and
636             product_info.properties.is_SALOME_module == "yes")
637
638 def product_is_smesh_plugin(product_info):
639     '''Know if a product is a SMESH plugin
640     
641     :param product_info Config: The configuration specific to 
642                                the product
643     :return: True if the product is a SMESH plugin, else False
644     :rtype: boolean
645     '''
646     return ("properties" in product_info and
647             "smesh_plugin" in product_info.properties and
648             product_info.properties.smesh_plugin == "yes")
649
650 def product_is_cpp(product_info):
651     '''Know if a product is cpp
652     
653     :param product_info Config: The configuration specific to 
654                                the product
655     :return: True if the product is a cpp, else False
656     :rtype: boolean
657     '''
658     return ("properties" in product_info and
659             "cpp" in product_info.properties and
660             product_info.properties.cpp == "yes")
661
662 def product_compiles(product_info):
663     '''Know if a product compiles or not (some products do not have a 
664        compilation procedure)
665     
666     :param product_info Config: The configuration specific to 
667                                the product
668     :return: True if the product compiles, else False
669     :rtype: boolean
670     '''
671     return not("properties" in product_info and
672             "compilation" in product_info.properties and
673             product_info.properties.compilation == "no")
674
675 def product_has_script(product_info):
676     '''Know if a product has a compilation script
677     
678     :param product_info Config: The configuration specific to 
679                                the product
680     :return: True if the product it has a compilation script, else False
681     :rtype: boolean
682     '''
683     if "build_source" not in product_info:
684         # Native case
685         return False
686     build_src = product_info.build_source
687     return build_src.lower() == 'script'
688
689 def product_has_env_script(product_info):
690     '''Know if a product has an environment script
691     
692     :param product_info Config: The configuration specific to 
693                                the product
694     :return: True if the product it has an environment script, else False
695     :rtype: boolean
696     '''
697     return "environ" in product_info and "env_script" in product_info.environ
698
699 def product_has_patches(product_info):
700     '''Know if a product has one or more patches
701     
702     :param product_info Config: The configuration specific to 
703                                the product
704     :return: True if the product has one or more patches
705     :rtype: boolean
706     '''
707     return "patches" in product_info and len(product_info.patches) > 0
708
709 def product_has_logo(product_info):
710     '''Know if a product has a logo (YACSGEN generate)
711     
712     :param product_info Config: The configuration specific to 
713                                the product
714     :return: The path of the logo if the product has a logo, else False
715     :rtype: Str
716     '''
717     if ("properties" in product_info and
718             "logo" in product_info.properties):
719         return product_info.properties.logo
720     else:
721         return False
722
723 def product_has_salome_gui(product_info):
724     '''Know if a product has a SALOME gui
725     
726     :param product_info Config: The configuration specific to 
727                                the product
728     :return: True if the product has a SALOME gui, else False
729     :rtype: Boolean
730     '''
731     return ("properties" in product_info and
732             "has_salome_gui" in product_info.properties and
733             product_info.properties.has_salome_gui == "yes")
734
735 def product_is_mpi(product_info):
736     '''Know if a product has openmpi in its dependencies
737     
738     :param product_info Config: The configuration specific to 
739                                the product
740     :return: True if the product has openmpi inits dependencies
741     :rtype: boolean
742     '''
743     return "openmpi" in product_info.depend
744
745 def product_is_generated(product_info):
746     '''Know if a product is generated (YACSGEN)
747     
748     :param product_info Config: The configuration specific to 
749                                the product
750     :return: True if the product is generated
751     :rtype: boolean
752     '''
753     return ("properties" in product_info and
754             "generate" in product_info.properties and
755             product_info.properties.generate == "yes")
756
757 def get_product_components(product_info):
758     '''Get the component list to generate with the product
759     
760     :param product_info Config: The configuration specific to 
761                                the product
762     :return: The list of names of the components
763     :rtype: List
764     
765     '''
766     if not product_is_generated(product_info):
767         return []
768     
769     compo_list = []
770     if "component_name" in product_info:
771         compo_list = product_info.component_name
772     
773         if isinstance(compo_list, str):
774             compo_list = [ compo_list ]
775
776     return compo_list