+
+def check_path(path, ext=[]):
+ '''Construct a text with the input path and "not found" if it does not
+ exist.
+
+ :param path Str: the path to check.
+ :param ext List: An extension. Verify that the path extension
+ is in the list
+ :return: The string of the path with information
+ :rtype: Str
+ '''
+ # check if file exists
+ if not os.path.exists(path):
+ return "'%s'" % path + " " + src.printcolors.printcError(_(
+ "** not found"))
+
+ # check extension
+ if len(ext) > 0:
+ fe = os.path.splitext(path)[1].lower()
+ if fe not in ext:
+ return "'%s'" % path + " " + src.printcolors.printcError(_(
+ "** bad extension"))
+
+ return path
+
+def show_product_info(config, name, logger):
+ '''Display on the terminal and logger information about a product.
+
+ :param config Config: the global configuration.
+ :param name Str: The name of the product
+ :param logger Logger: The logger instance to use for the display
+ '''
+
+ logger.write(_("%s is a product\n") % src.printcolors.printcLabel(name), 2)
+ pinfo = src.product.get_product_config(config, name)
+
+ if "depend" in pinfo:
+ src.printcolors.print_value(logger, "depends on", sorted(pinfo.depend), 2)
+
+ if "opt_depend" in pinfo:
+ src.printcolors.print_value(logger, "optional", sorted(pinfo.opt_depend), 2)
+
+ # information on pyconf
+ logger.write("\n", 2)
+ logger.write(src.printcolors.printcLabel("configuration:") + "\n", 2)
+ if "from_file" in pinfo:
+ src.printcolors.print_value(logger,
+ "pyconf file path",
+ pinfo.from_file,
+ 2)
+ if "section" in pinfo:
+ src.printcolors.print_value(logger,
+ "section",
+ pinfo.section,
+ 2)
+
+ # information on prepare
+ logger.write("\n", 2)
+ logger.write(src.printcolors.printcLabel("prepare:") + "\n", 2)
+
+ is_dev = src.product.product_is_dev(pinfo)
+ method = pinfo.get_source
+ if is_dev:
+ method += " (dev)"
+ src.printcolors.print_value(logger, "get method", method, 2)
+
+ if method == 'cvs':
+ src.printcolors.print_value(logger, "server", pinfo.cvs_info.server, 2)
+ src.printcolors.print_value(logger, "base module",
+ pinfo.cvs_info.module_base, 2)
+ src.printcolors.print_value(logger, "source", pinfo.cvs_info.source, 2)
+ src.printcolors.print_value(logger, "tag", pinfo.cvs_info.tag, 2)
+
+ elif method == 'svn':
+ src.printcolors.print_value(logger, "repo", pinfo.svn_info.repo, 2)
+
+ elif method == 'git':
+ src.printcolors.print_value(logger, "repo", pinfo.git_info.repo, 2)
+ src.printcolors.print_value(logger, "tag", pinfo.git_info.tag, 2)
+
+ elif method == 'archive':
+ src.printcolors.print_value(logger,
+ "get from",
+ check_path(pinfo.archive_info.archive_name),
+ 2)
+
+ if 'patches' in pinfo:
+ for patch in pinfo.patches:
+ src.printcolors.print_value(logger, "patch", check_path(patch), 2)
+
+ if src.product.product_is_fixed(pinfo):
+ src.printcolors.print_value(logger, "install_dir",
+ check_path(pinfo.install_dir), 2)
+
+ if src.product.product_is_native(pinfo) or src.product.product_is_fixed(pinfo):
+ return
+
+ # information on compilation
+ if src.product.product_compiles(pinfo):
+ logger.write("\n", 2)
+ logger.write(src.printcolors.printcLabel("compile:") + "\n", 2)
+ src.printcolors.print_value(logger,
+ "compilation method",
+ pinfo.build_source,
+ 2)
+
+ if pinfo.build_source == "script" and "compil_script" in pinfo:
+ src.printcolors.print_value(logger,
+ "Compilation script",
+ pinfo.compil_script,
+ 2)