def exit(self, status=0, message=None): if message: self._print_message( colorize(message, enabling=ColoredSetting().is_colorize(sys.stderr), **self.__styles['error']), sys.stderr) sys.exit(status)
def print_help(self, file=sys.stdout): help = self.format_help() help = help[0].upper() + help[1:] self._print_message( colorize(help, enabling=ColoredSetting().is_colorize(file), **self.__styles['help']), file)
def print_usage(self, file=sys.stdout): usage = self.format_usage() usage = usage[0].upper() + usage[1:] self._print_message( colorize(usage, enabling=ColoredSetting().is_colorize(file), **self.__styles['usage']), file)
def print_error(self, message): message = '%(prog)s: ERROR: %(message)s\n' % { 'prog': self.prog, 'message': message } self._print_message( colorize(message, enabling=ColoredSetting().is_colorize(sys.stderr), **self.__styles['error']), sys.stderr)
def to_string(self): aligned_width_of_columns = map( lambda x: align_size(x, self.__align_boundary), self.__max_size_of_columns) aligned_width_of_columns = [ i if j == None else j for i, j in zip(aligned_width_of_columns, self.__fixed_width_of_fields) ] fmtstr = self.__padding_characters.join([ '{:%s%d}' % (_, __) for _, __ in zip(self.__field_alignments, aligned_width_of_columns) ]) string = colorize(fmtstr.format(*self.__fields), enabling=self.__enable_painting, **self.__field_paint) string += os.linesep paletteiter = iter(RingLooper(*self.__palette_paints)) for r in self.__records: string += colorize(fmtstr.format(*r), enabling=self.__enable_painting, **next(paletteiter)) string += os.linesep return string
def to_string(self): aligned_width_of_columns = map( lambda x: align_size(x, self.__align_boundary), self.__max_size_of_columns) if self.__fixed_width_of_columns != None: aligned_width_of_columns = [ i if j == None else j for i, j in zip( aligned_width_of_columns, self.__fixed_width_of_columns) ] fmtstr = self.__padding_characters.join([ '{:%s%d}' % (_, __) for _, __ in zip(self.__column_alignments, aligned_width_of_columns) ]) string = '' paletteiter = iter(RingLooper(*self.__palette_paints)) for group in self.__groups: group = transposelist(group) paint = next(paletteiter) for row in group: string += colorize(fmtstr.format(*row), enabling=self.__enable_painting, **paint) string += os.linesep return string
def format(self, record): msg = super().format(record) return str( colorize(msg, enabling=ColoredSetting().is_colorize(self.__stream), **_levelstyles.get(record.levelname, {})))