def dry_run(easyconfigs, modtool, short=False): """ Compose dry run overview for supplied easyconfigs: * [ ] for unavailable * [x] for available * [F] for forced * [R] for rebuild :param easyconfigs: list of parsed easyconfigs (EasyConfig instances) :param modtool: ModulesTool instance to use :param short: use short format for overview: use a variable for common prefixes """ lines = [] if build_option('robot_path') is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append( "Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, modtool, retain_all_deps=True) unbuilt_specs = skip_available(all_specs, modtool) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) listed_ec_paths = [spec['spec'] for spec in easyconfigs] var_name = 'CFGS' common_prefix = det_common_path_prefix( [spec['spec'] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len( common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = ' ' elif build_option('force') and spec['spec'] in listed_ec_paths: ans = 'F' elif build_option('rebuild') and spec['spec'] in listed_ec_paths: ans = 'R' else: ans = 'x' if spec['ec'].short_mod_name != spec['ec'].full_mod_name: mod = "%s | %s" % (spec['ec'].mod_subdir, spec['ec'].short_mod_name) else: mod = spec['ec'].full_mod_name if short: item = os.path.join('$%s' % var_name, spec['spec'][len(common_prefix) + 1:]) else: item = spec['spec'] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) return '\n'.join(lines)
def test_common_path_prefix(self): """Test get common path prefix for a list of paths.""" self.assertEqual(ft.det_common_path_prefix(['/foo/bar/foo', '/foo/bar/baz', '/foo/bar/bar']), '/foo/bar') self.assertEqual(ft.det_common_path_prefix(['/foo/bar/', '/foo/bar/baz', '/foo/bar']), '/foo/bar') self.assertEqual(ft.det_common_path_prefix(['/foo/bar', '/foo']), '/foo') self.assertEqual(ft.det_common_path_prefix(['/foo/bar/']), '/foo/bar') self.assertEqual(ft.det_common_path_prefix(['/foo/bar', '/bar', '/foo']), None) self.assertEqual(ft.det_common_path_prefix(['foo', 'bar']), None) self.assertEqual(ft.det_common_path_prefix(['foo']), None) self.assertEqual(ft.det_common_path_prefix([]), None)
def test_common_path_prefix(self): """Test get common path prefix for a list of paths.""" self.assertEqual(ft.det_common_path_prefix(["/foo/bar/foo", "/foo/bar/baz", "/foo/bar/bar"]), "/foo/bar") self.assertEqual(ft.det_common_path_prefix(["/foo/bar/", "/foo/bar/baz", "/foo/bar"]), "/foo/bar") self.assertEqual(ft.det_common_path_prefix(["/foo/bar", "/foo"]), "/foo") self.assertEqual(ft.det_common_path_prefix(["/foo/bar/"]), "/foo/bar") self.assertEqual(ft.det_common_path_prefix(["/foo/bar", "/bar", "/foo"]), None) self.assertEqual(ft.det_common_path_prefix(["foo", "bar"]), None) self.assertEqual(ft.det_common_path_prefix(["foo"]), None) self.assertEqual(ft.det_common_path_prefix([]), None)
def dry_run(easyconfigs, modtool, short=False): """ Compose dry run overview for supplied easyconfigs: * [ ] for unavailable * [x] for available * [F] for forced * [R] for rebuild :param easyconfigs: list of parsed easyconfigs (EasyConfig instances) :param modtool: ModulesTool instance to use :param short: use short format for overview: use a variable for common prefixes """ lines = [] if build_option('robot_path') is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append("Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, modtool, retain_all_deps=True, raise_error_missing_ecs=False) unbuilt_specs = skip_available(all_specs, modtool) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) listed_ec_paths = [spec['spec'] for spec in easyconfigs] var_name = 'CFGS' common_prefix = det_common_path_prefix([spec['spec'] for spec in all_specs if spec['spec'] is not None]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len(common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = ' ' elif build_option('force') and spec['spec'] in listed_ec_paths: ans = 'F' elif build_option('rebuild') and spec['spec'] in listed_ec_paths: ans = 'R' else: ans = 'x' if spec['ec'] is not None and spec['ec'].short_mod_name != spec['ec'].full_mod_name: mod = "%s | %s" % (spec['ec'].mod_subdir, spec['ec'].short_mod_name) else: mod = spec['full_mod_name'] if spec['spec'] is None: item = "(no easyconfig file found)" elif short: item = os.path.join('$%s' % var_name, spec['spec'][len(common_prefix) + 1:]) else: item = spec['spec'] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) return '\n'.join(lines)
def print_dry_run(easyconfigs, short=False, build_specs=None): """ Print dry run information @param easyconfigs: list of easyconfig files @param short: print short output (use a variable for the common prefix) @param build_specs: dictionary specifying build specifications (e.g. version, toolchain, ...) """ lines = [] if build_option('robot_path') is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append( "Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, build_specs=build_specs, retain_all_deps=True) unbuilt_specs = skip_available(all_specs, testing=True) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) listed_ec_paths = [spec['spec'] for spec in easyconfigs] var_name = 'CFGS' common_prefix = det_common_path_prefix( [spec['spec'] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len( common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = ' ' elif build_option('force') and spec['spec'] in listed_ec_paths: ans = 'F' else: ans = 'x' if spec['ec'].short_mod_name != spec['ec'].full_mod_name: mod = "%s | %s" % (spec['ec'].mod_subdir, spec['ec'].short_mod_name) else: mod = spec['ec'].full_mod_name if short: item = os.path.join('$%s' % var_name, spec['spec'][len(common_prefix) + 1:]) else: item = spec['spec'] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) silent = build_option('silent') print_msg('\n'.join(lines), log=_log, silent=silent, prefix=False)
def dry_run(easyconfigs, modtool, short=False): """ Compose dry run overview for supplied easyconfigs: * [ ] for unavailable * [x] for available * [F] for forced * [R] for rebuild @param easyconfigs: list of parsed easyconfigs (EasyConfig instances) @param modtool: ModulesTool instance to use @param short: use short format for overview: use a variable for common prefixes """ lines = [] if build_option("robot_path") is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append("Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, modtool, retain_all_deps=True) unbuilt_specs = skip_available(all_specs, modtool) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) listed_ec_paths = [spec["spec"] for spec in easyconfigs] var_name = "CFGS" common_prefix = det_common_path_prefix([spec["spec"] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len(common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = " " elif build_option("force") and spec["spec"] in listed_ec_paths: ans = "F" elif build_option("rebuild") and spec["spec"] in listed_ec_paths: ans = "R" else: ans = "x" if spec["ec"].short_mod_name != spec["ec"].full_mod_name: mod = "%s | %s" % (spec["ec"].mod_subdir, spec["ec"].short_mod_name) else: mod = spec["ec"].full_mod_name if short: item = os.path.join("$%s" % var_name, spec["spec"][len(common_prefix) + 1 :]) else: item = spec["spec"] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) return "\n".join(lines)
def dry_run(easyconfigs, short=False, build_specs=None): """ Compose dry run overview for supplied easyconfigs ([ ] for unavailable, [x] for available, [F] for forced) @param easyconfigs: list of parsed easyconfigs (EasyConfig instances) @param short: use short format for overview: use a variable for common prefixes @param build_specs: dictionary specifying build specifications (e.g. version, toolchain, ...) """ lines = [] if build_option('robot_path') is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append("Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, build_specs=build_specs, retain_all_deps=True) unbuilt_specs = skip_available(all_specs) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) listed_ec_paths = [spec['spec'] for spec in easyconfigs] var_name = 'CFGS' common_prefix = det_common_path_prefix([spec['spec'] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len(common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = ' ' elif build_option('force') and spec['spec'] in listed_ec_paths: ans = 'F' else: ans = 'x' if spec['ec'].short_mod_name != spec['ec'].full_mod_name: mod = "%s | %s" % (spec['ec'].mod_subdir, spec['ec'].short_mod_name) else: mod = spec['ec'].full_mod_name if short: item = os.path.join('$%s' % var_name, spec['spec'][len(common_prefix) + 1:]) else: item = spec['spec'] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) return '\n'.join(lines)
def print_dry_run(easyconfigs, short=False, build_specs=None): """ Print dry run information @param easyconfigs: list of easyconfig files @param short: print short output (use a variable for the common prefix) @param build_specs: dictionary specifying build specifications (e.g. version, toolchain, ...) """ lines = [] if build_option('robot_path') is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append("Dry run: printing build status of easyconfigs and dependencies") all_specs = resolve_dependencies(easyconfigs, build_specs=build_specs, retain_all_deps=True) unbuilt_specs = skip_available(all_specs, testing=True) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) var_name = 'CFGS' common_prefix = det_common_path_prefix([spec['spec'] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len(common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = ' ' else: ans = 'x' if spec['ec'].short_mod_name != spec['ec'].full_mod_name: mod = "%s | %s" % (spec['ec'].mod_subdir, spec['ec'].short_mod_name) else: mod = spec['ec'].full_mod_name if short: item = os.path.join('$%s' % var_name, spec['spec'][len(common_prefix) + 1:]) else: item = spec['spec'] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) silent = build_option('silent') print_msg('\n'.join(lines), log=_log, silent=silent, prefix=False)
def print_dry_run(easyconfigs, short=False, build_options=None, build_specs=None): """ Print dry run information @param easyconfigs: list of easyconfig files @param short: print short output (use a variable for the common prefix) @param build_options: dictionary specifying build options (e.g. robot_path, check_osdeps, ...) @param build_specs: dictionary specifying build specifications (e.g. version, toolchain, ...) """ lines = [] if build_options.get("robot_path", None) is None: lines.append("Dry run: printing build status of easyconfigs") all_specs = easyconfigs else: lines.append("Dry run: printing build status of easyconfigs and dependencies") build_options = copy.deepcopy(build_options) build_options.update({"retain_all_deps": True, "check_osdeps": False}) all_specs = resolve_dependencies(easyconfigs, build_options=build_options, build_specs=build_specs) unbuilt_specs = skip_available(all_specs, testing=True) dry_run_fmt = " * [%1s] %s (module: %s)" # markdown compatible (list of items with checkboxes in front) var_name = "CFGS" common_prefix = det_common_path_prefix([spec["spec"] for spec in all_specs]) # only allow short if common prefix is long enough short = short and common_prefix is not None and len(common_prefix) > len(var_name) * 2 for spec in all_specs: if spec in unbuilt_specs: ans = " " else: ans = "x" mod = det_full_module_name(spec["ec"]) if short: item = os.path.join("$%s" % var_name, spec["spec"][len(common_prefix) + 1 :]) else: item = spec["spec"] lines.append(dry_run_fmt % (ans, item, mod)) if short: # insert after 'Dry run:' message lines.insert(1, "%s=%s" % (var_name, common_prefix)) silent = build_options.get("silent", False) print_msg("\n".join(lines), log=_log, silent=silent, prefix=False)