def cylc_header(width=None): """Print copyright and license information.""" width = width or get_width() lmax = (max(len(strip(line)) for line in LICENSE) + len(strip(LOGO[0]))) if width >= lmax + 1: header = '\n'.join( ('{0} {1}').format(*x) for x in zip_longest(LOGO, LICENSE)) else: header = '\n'.join(LOGO) + '\n' + '\n'.join(LICENSE) return f"\n{header}\n"
def colorize(self, template, **kwargs): template = self._theme[template] if not self._colored: template = ansimarkup.strip(template) else: template = ansimarkup.parse(template) return template.format(**kwargs)
def cylc_header(width=None): """Print copyright and license information.""" if not width: width = get_width() cylc_license = '\n\n' + LICENCE + '\n\n' license_lines = cylc_license.splitlines() lmax = max(len(line) for line in license_lines) tlmax = lmax + len(strip(LOGO_LINES[0])) lpad = int((width - tlmax) / 2) * ' ' return lpad + f'\n{lpad}'.join( ('{0} {1: ^%s}' % lmax).format(*x) for x in zip_longest( LOGO_LINES, license_lines, fillvalue=' ' * ( len(LOGO_LINES[-1]) + 1 ) ) )
def test_ansi_dont_strip_unrelated(writer): logger.add(writer, format="{message} {extra[trap]}", colorize=False) logger.bind(trap="<red>B</red>").opt(ansi=True).debug("<red>A</red>") assert writer.read( ) == ansimarkup.strip("<red>A</red>") + " <red>B</red>\n"
def test_ansi_not_colorize(writer): logger.add(writer, format="<red>a</red> {message}", colorize=False) logger.opt(ansi=True).debug("<blue>b</blue>") assert writer.read() == ansimarkup.strip("<red>a</red> <blue>b</blue>\n")