def _test_sourcecode(S): opdef = S.user_op._opdef assert opdef logger = _CopyLogger() sourcecode_src = opdef.guildfile.dir sourcecode_select = op_util.sourcecode_select_for_opdef(opdef) op_util.copy_sourcecode(sourcecode_src, sourcecode_select, None, handler_cls=logger.handler_cls) cli.out("Copying from %s" % cmd_impl_support.cwd_desc(logger.root)) cli.out("Rules:") for rule in logger.select.rules: cli.out(" %s" % _format_file_select_rule(rule)) if logger.select.disabled: assert not logger.selected, logger.selected assert not logger.skipped, logger.skipped cli.out("Source code copy disabled") else: cli.out("Selected for copy:") for path in logger.selected: cli.out(cli.style(" %s" % path, fg="yellow")) cli.out("Skipped:") for path in logger.skipped: cli.out(cli.style(" %s" % path, dim=True))
def _set_tags_preview(args): lines = ["You are about to modify tags for the following runs:"] if args.sync_labels: lines.append( cli.style("Labels are updated to reflect the latest tags.", fg="yellow")) else: lines.append( cli.style( ("Labels are not updated - use --sync-labels to " "apply changes run labels."), fg="yellow", )) return "\n".join(lines)
def _scalar_info(run, args): try: return _scalar_info_impl(run, args) except Exception as e: if log.getEffectiveLevel() <= logging.DEBUG: log.exception("get scalars") return cli.style("ERROR: %s" % e, fg="yellow")
def _format_output_line(stream, line): if stream == 1: return cli.style(line, fg="red") return line
def _source_resolution_error(source, dep, e): msg = "could not resolve '%s' in %s resource: %s" % (source, dep.resdef.name, e) if source.help: msg += "\n%s" % cli.style(source.help, fg="yellow") raise OpDependencyError(msg)
def format_warn(s): return cli.style(s, fg="yellow")
def pattern_matches(self, pattern, matches, vals): msg = self._format_pattern_matches(pattern, matches, vals) cli.out(cli.style(msg, fg="yellow"))
def pattern_no_matches(self, pattern): msg = self._format_pattern_no_matches(pattern) cli.out(cli.style(msg, dim=True))
def _dim_style(s, apply_style): if apply_style: return cli.style(s, dim=True) return s
def _empty_style(s, apply_style): # Pad a string with an empty style for alignment in tables. if apply_style: return s + cli.style("", dim=True) return s