2022-07-15 12:40 UTC

colorsysplus

NAME
    colorsysplus

DESCRIPTION
    This module supplements the standard colorsys module with functions for
    converting RGB to and from the following:
    
      * CMYK
      * hexadecimal color strings (e.g. HTML colors)
      * terminal color indices & ANSI escape codes
      * Xonotic color codes
    
    Some functionality may be incomplete. See the code and documention for details.

PACKAGE CONTENTS
    __main__
    format
    log
    text

CLASSES
    builtins.object
        QuietUnbufferedUnblockedTerminal
    
    class QuietUnbufferedUnblockedTerminal(builtins.object)
     |  A wrapper object to configure the terminal for determining current RGB color
     |  values.
     |  
     |  Methods defined here:
     |  
     |  __enter__(self)
     |  
     |  __exit__(self, typ, val, traceback)
     |  
     |  __init__(self)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  term_init(self)
     |      Initialize the terminal.
     |      
     |      This does the following to facilitate terminal interaction for determining
     |      color values:
     |      
     |        * disables echo
     |        * disables buffering
     |        * disables blocking
     |      
     |      This should be called before invoking term_to_queried_rgb().
     |      
     |      Returns a terminal save state to pass to term_reset().
     |  
     |  term_reset(self)
     |      Reset the terminal.
     |      
     |      See term_init().
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

FUNCTIONS
    ansi_sgr(fg=None, bg=None, term_colors=None, **kwargs)
        Get the ANSI escape sequence for the selected graphic rendition. This function
        accepts all keywords in ANSI_SGR_KEYWORDS_TO_PARAMS, the values of which
        should be boolean and indicate if that parameter should be set.
    
    ansi_sgr_color(color, fg=True, truecolor=False, term_colors=None)
        Get the appropriate sequence for the given color. If truecolor is false,
        colors will be cast to nearest color index.
    
    ansi_to_rgb(ansi, background=False, term_colors=None)
        Attempt to convert an ANSI escape code to RGB values.
    
    ansi_to_term(ansi, term_colors=None)
        Attempt to convert an ANSI escape code to a terminal color index.
    
    ansi_to_term_or_rgb(ansi, background=False)
        Attempt to parse a color value from an ANSI SGR escape sequence. This will
        return either a terminal color index or an RGB 3-tuple. Check the type.
        
        Parse background color if `background` is True.
    
    cmyk_to_rgb(c, m, y, k)
        Convert CMYK to RGB.
        
        This seems to be one of the most commonly used algorithms but CMYK values
        vary between printers and there is no canonical formula. Do not rely on these
        values for anything more than qualitative approximations.
    
    get_term_colors(timeout=1000)
        Iterate over the real RGB values for the current terminal.
    
    hex_to_rgb(hexstr, alpha=False)
        Convert a hexadecimal color string to RGB(A).
        
        Variable widths are recognized (e.g. #40f, #4400ff, #444000fff). The hash
        is optional. If the string length is a multiple of 3 then it is
        interpreted as RGB unless "alpha" is True. If it is a multiple of 4 then it
        is interpreted as RGBA. Any other multiple raises a ValueError.
        
        Args:
            hexstr:
                An RGB(A) color in hexadecimal format, with option leading "#".
        
            alpha:
                If True, the string is interpretted as an RGBA color even if the
                length is a multiple of 3.
        
        Returns:
            A 3-tuple or RGB values in the range [0-1.0] or a 4-tuple of RGBA values
            in the same range.
        
        Raises:
            ValueError if hexstr is not a hexadecimal string with a length that is a
            multiple of 3 or 4.
    
    parse_ansi_sgr(ansi)
        Attempt to parse an ANSI SGR escape sequence. This will return a dictionary
        with entries that parallel the keyword arguments of ansi_sgr with some
        modifications where necessary, or None if the sequence is not an
        ANSI SGR escape.
    
    remove_ansi(text)
        Remove ANSI escape codes from a string.
    
    rgb_to_ansi(r, g, b, background=False, term_colors=None)
        Convert RGB values to ANSI escapes.
    
    rgb_to_cmyk(r, g, b)
        Convert RGB to CMYK.
        
        This seems to be one of the most commonly used algorithms but CMYK values
        vary between printers and there is no canonical formula. Do not rely on these
        values for anything more than qualitative approximations.
    
    rgb_to_hex(r, g, b, alpha=None, width=2, include_hash=True)
        Convert RGB to a hexadecimal color string.
        
        alpha: Optional alpha channel value, in the range [0.0, 1.0].
        
        width: The number of characters to use for each field.
        
        include_hash: Prefix the string with a hash.
    
    rgb_to_term(r, g, b, n=256, colors=None)
        Convert RGB to a terminal color index.
        
        n:
          The number of colors to use. Currently only 256 is supported, but see
          "colors" below.
        
        colors:
          A list of RGB values corresponding to terminal colors. The index of the list
          is the terminal color. Returns the best approximation using a least squares
          method. The values should be in the range of 0.0 to 1.0.
        
        If n is not 256 and no colors are provided, returns None.
    
    rgb_to_xonotic(r, g, b, abbreviate=True)
        Convert RGB to a Xonotic color escape code.
    
    run_example(words)
        Print some colored text to the terminal as an example.
    
    term_get_closest(arg, values)
        Return the value in values that is closest to arg in absolute distance.
        
        arg and values must lie in the range [0.0, 1.0] and values must be sorted in
        increasing order.
    
    term_get_closest_256_color(arg)
        Get the closest matching terminal color for the given argument.
    
    term_get_closest_256_greyscale(arg)
        Get the closest matching terminal greyscale value for the given argument.
    
    term_to_ansi(color)
        Convert terminal color to an ANSI escape code.
    
    term_to_queried_rgb(index, poll, timeout=-1, retries=5)
        Convert a terminal color index to RGB values.
        
        This should be called within a `with` block using
        QuietUnbufferedUnblockedTerminal.
        
        poll: poll object returned by QuietUnbufferedUnblockedTerminal's enter method.
        
        timeout: The timeout when polling.
        
        retries: The maximum number of retries when reading from stdout.
    
    term_to_rgb(index, n=256, colors=None)
        Convert a terminal color index to RGB.
        
        n: The number of colors to use. Currently only 256 is supported, but see
        "colors" below.
        
        colors: A list of RGB values corresponding to terminal colors. The index of
        the list is the terminal color index. Returns None on IndexError.
        
        If n is not 256 and no colors are provided, returns None.
    
    wavelength_to_rgb(w, bg=(0.0, 0.0, 0.0), mode=None)
        Convert a wavelength (in nanometers) to RGB.
        
        This is a work in progress and will never be truly accurate due to the
        limitations of how colors are displayed on screens. Relevant links:
        
          * http://mintaka.sdsu.edu/GF/explain/optics/rendering.html
          * http://www.fourmilab.ch/documents/specrend/
          * http://www.physics.sfasu.edu/astro/color/spectra.html
          * http://mintaka.sdsu.edu/GF/explain/optics/color/color.html
        
        Note that I have not read all of them yet, so I hae not (yet) taken all of the
        advice given.
        
        bg: The background color into which the values should fade.
    
    xonotic_to_rgb(esc)
        Convert a Xonotic color escape code to RGB.
        
        These should omit the leading caret (^).

DATA
    ANSI_ESC = '\x1b'
    ANSI_SGR_KEYWORDS_TO_PARAMS = {'blink': '5', 'bold': '1', 'negative': ...
    ANSI_SGR_PARAMS_TO_KEYWORDS = {'0': 'reset', '1': 'bold', '5': 'blink'...
    ANSI_SGR_REGEX = re.compile('(\x1b\\[.+?m)')
    TERM_256_COLOR_STEPS = (0.0, 0.37254901960784315, 0.5294117647058824, ...
    TERM_256_GREYSCALE_STEPS = (0.03137254901960784, 0.07058823529411765, ...
    TERM_BASIC_COLORS = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)...
    TERM_BASIC_COLOR_NAMES = ('black', 'red', 'green', 'yellow', 'blue', '...
    XONOTIC_LONG_TO_SHORT = {'x000': '0', 'x00f': '4', 'x0f0': '2', 'x0ff'...
    XONOTIC_SHORT_TO_LONG = {'0': 'x000', '1': 'xf00', '2': 'x0f0', '3': '...

colorsysplus.__main__

NAME
    colorsysplus.__main__ - Run the main function from colorsysplus as an example.

colorsysplus.format

NAME
    colorsysplus.format - Support for colors in format, percent-style and template strings.

CLASSES
    builtins.object
        ColorPercentStyle
    string.Formatter(builtins.object)
        ColorFormatter
    string.Template(builtins.object)
        ColorTemplate
    
    class ColorFormatter(string.Formatter)
     |  ColorFormatter(*args, color_char='@', output_type='ansi', **kwargs)
     |  
     |  Subclass of string.Formatter that supports color codes in format
     |  specification strings.
     |  
     |  Method resolution order:
     |      ColorFormatter
     |      string.Formatter
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, *args, color_char='@', output_type='ansi', **kwargs)
     |      Args:
     |          *args, **kwargs:
     |              Positional and keyword arguments passed through to
     |              string.Formatter.
     |      
     |          color_char:
     |              The character used to indicate a color after the type in the
     |              format specification. With the default value "@", the following
     |              will insert the value of field "red" and color it red:
     |              "{red:s@f00}".  This should be set to a value that will not
     |              occur elsewhere in the format specification.
     |      
     |          output_type:
     |              The  color output type.
     |  
     |  colorize(self, fmt, output_type=None)
     |      Add colors to the format.
     |  
     |  format_field(self, value, format_spec)
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from string.Formatter:
     |  
     |  check_unused_args(self, used_args, args, kwargs)
     |  
     |  convert_field(self, value, conversion)
     |  
     |  format(self, format_string, /, *args, **kwargs)
     |  
     |  get_field(self, field_name, args, kwargs)
     |      # given a field_name, find the object it references.
     |      #  field_name:   the field being looked up, e.g. "0.name"
     |      #                 or "lookup[3]"
     |      #  used_args:    a set of which args have been used
     |      #  args, kwargs: as passed in to vformat
     |  
     |  get_value(self, key, args, kwargs)
     |  
     |  parse(self, format_string)
     |      # returns an iterable that contains tuples of the form:
     |      # (literal_text, field_name, format_spec, conversion)
     |      # literal_text can be zero length
     |      # field_name can be None, in which case there's no
     |      #  object to format and output
     |      # if field_name is not None, it is looked up, formatted
     |      #  with format_spec and conversion and then used
     |  
     |  vformat(self, format_string, args, kwargs)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from string.Formatter:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
    
    class ColorPercentStyle(builtins.object)
     |  ColorPercentStyle(fmt, color_char='@', output_type='ansi')
     |  
     |  Colorize percent-style format strings with custom color codes.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, fmt, color_char='@', output_type='ansi')
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  __mod__(self, arg)
     |      Colorize a percent-style format string.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
    
    class ColorTemplate(string.Template)
     |  ColorTemplate(template, color_char='@', output_type='ansi')
     |  
     |  Subclass of string.Template that supports color codes affixed to
     |  identifiers.
     |  
     |  Method resolution order:
     |      ColorTemplate
     |      string.Template
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, template, color_char='@', output_type='ansi')
     |      Args:
     |          template:
     |              The template string, with optional color codes after the
     |              identifiers.
     |      
     |          color_char:
     |              The character used to indicate a color after the identifier.
     |              With the default value "@", the string "${var@00f}" would be
     |              replaced by the value of "var" and colored blue after a call to
     |              substitute. The character must not be a valid identifier
     |              character.
     |      
     |          output_type:
     |              The  color output type.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  pattern = re.compile('\n            \\$(?:\n              ...identifie...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from string.Template:
     |  
     |  safe_substitute(self, mapping={}, /, **kws)
     |  
     |  substitute(self, mapping={}, /, **kws)
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from string.Template:
     |  
     |  __init_subclass__() from builtins.type
     |      This method is called when a class is subclassed.
     |      
     |      The default implementation does nothing. It may be
     |      overridden to extend subclasses.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from string.Template:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from string.Template:
     |  
     |  braceidpattern = None
     |  
     |  delimiter = '$'
     |  
     |  flags = re.IGNORECASE
     |  
     |  idpattern = '(?a:[_a-z][_a-z0-9]*)'

FUNCTIONS
    colorize_fmt(fmt, style='{', output_type='ansi', color_char='@')
        Colorize a format or template string.
        
        Args:
            fmt:
                A format or template string in one of the supported styles.
        
            style:
                One of "{", "%" or "$", which correspond to Python format strings,
                percent-style strings or templates, respectively.
        
            output_type:
                The output type.
        
        Returns:
            A format string with color codes.
    
    format_with_color(fmt, fields, style='{', output_type='ansi', color_char='@')
        Format a string.
        
        Args:
            fmt:
                A format or template string in one of the supported styles.
        
            fields:
                A dictionary mapping field names to values.
        
            style:
                One of "{", "%" or "$", which correspond to Python format strings,
                percent-style strings or templates, respectively.
        
            output_type:
                The output type.
        
        Returns:
            The formatted string.
    
    run_example()
        Print different output formats for each format style.

colorsysplus.log

NAME
    colorsysplus.log - Formatters for colorized logging.

CLASSES
    logging.Formatter(builtins.object)
        ColorFormatter
        LevelDependentFormatter
    
    class ColorFormatter(logging.Formatter)
     |  ColorFormatter(*args, fmt=None, style='%', output_type='ansi', color_char='@', **kwargs)
     |  
     |  Format log messages with colors.
     |  
     |  Method resolution order:
     |      ColorFormatter
     |      logging.Formatter
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, *args, fmt=None, style='%', output_type='ansi', color_char='@', **kwargs)
     |      Initialize the formatter with specified format strings.
     |      
     |      Initialize the formatter either with the specified format string, or a
     |      default as described above. Allow for specialized date formatting with
     |      the optional datefmt argument. If datefmt is omitted, you get an
     |      ISO8601-like (or RFC 3339-like) format.
     |      
     |      Use a style parameter of '%', '{' or '$' to specify that you want to
     |      use one of %-formatting, :meth:`str.format` (``{}``) formatting or
     |      :class:`string.Template` formatting in your format string.
     |      
     |      .. versionchanged:: 3.2
     |         Added the ``style`` parameter.
     |  
     |  format(self, record)
     |      Format the specified record as text.
     |      
     |      The record's attribute dictionary is used as the operand to a
     |      string formatting operation which yields the returned string.
     |      Before formatting the dictionary, a couple of preparatory steps
     |      are carried out. The message attribute of the record is computed
     |      using LogRecord.getMessage(). If the formatting string uses the
     |      time (as determined by a call to usesTime(), formatTime() is
     |      called to format the event time. If there is exception information,
     |      it is formatted using formatException() and appended to the message.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from logging.Formatter:
     |  
     |  formatException(self, ei)
     |      Format and return the specified exception information as a string.
     |      
     |      This default implementation just uses
     |      traceback.print_exception()
     |  
     |  formatMessage(self, record)
     |  
     |  formatStack(self, stack_info)
     |      This method is provided as an extension point for specialized
     |      formatting of stack information.
     |      
     |      The input data is a string as returned from a call to
     |      :func:`traceback.print_stack`, but with the last trailing newline
     |      removed.
     |      
     |      The base implementation just returns the value passed in.
     |  
     |  formatTime(self, record, datefmt=None)
     |      Return the creation time of the specified LogRecord as formatted text.
     |      
     |      This method should be called from format() by a formatter which
     |      wants to make use of a formatted time. This method can be overridden
     |      in formatters to provide for any specific requirement, but the
     |      basic behaviour is as follows: if datefmt (a string) is specified,
     |      it is used with time.strftime() to format the creation time of the
     |      record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used.
     |      The resulting string is returned. This function uses a user-configurable
     |      function to convert the creation time to a tuple. By default,
     |      time.localtime() is used; to change this for a particular formatter
     |      instance, set the 'converter' attribute to a function with the same
     |      signature as time.localtime() or time.gmtime(). To change it for all
     |      formatters, for example if you want all logging times to be shown in GMT,
     |      set the 'converter' attribute in the Formatter class.
     |  
     |  usesTime(self)
     |      Check if the format uses the creation time of the record.
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from logging.Formatter:
     |  
     |  converter = localtime(...)
     |      localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
     |                                tm_sec,tm_wday,tm_yday,tm_isdst)
     |      
     |      Convert seconds since the Epoch to a time tuple expressing local time.
     |      When 'seconds' is not passed in, convert the current time instead.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from logging.Formatter:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from logging.Formatter:
     |  
     |  default_msec_format = '%s,%03d'
     |  
     |  default_time_format = '%Y-%m-%d %H:%M:%S'
    
    class LevelDependentFormatter(logging.Formatter)
     |  LevelDependentFormatter(*args, formatters=None, **kwargs)
     |  
     |  Format log messages differently depending on log level. This delegates to
     |  other formatters.
     |  
     |  Method resolution order:
     |      LevelDependentFormatter
     |      logging.Formatter
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, *args, formatters=None, **kwargs)
     |      Args:
     |          *args:
     |              Positional Formatter arguments.
     |      
     |          formatters:
     |              A dictionary mapping log levels to formatter objects. The
     |              formatting of received messages will be delegated to these
     |              formatters if their level matches.
     |      
     |              Not all log levels are required. If a given message's level is
     |              absent from the dictionary, the format associated with the
     |              highest level below the message's level will be used. For
     |              example, if a format is given for logging.WARNING, it will be
     |              applied to logging.ERROR and logging.CRITICAL if these latter
     |              levels are not also given.
     |      
     |              If no level in the dictionary is below the message's level, the
     |              formatting will not be delegated.
     |      
     |          **kwargs:
     |              Keyword Formatter arguments.
     |  
     |  format(self, record)
     |      Format the specified record as text.
     |      
     |      The record's attribute dictionary is used as the operand to a
     |      string formatting operation which yields the returned string.
     |      Before formatting the dictionary, a couple of preparatory steps
     |      are carried out. The message attribute of the record is computed
     |      using LogRecord.getMessage(). If the formatting string uses the
     |      time (as determined by a call to usesTime(), formatTime() is
     |      called to format the event time. If there is exception information,
     |      it is formatted using formatException() and appended to the message.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from logging.Formatter:
     |  
     |  formatException(self, ei)
     |      Format and return the specified exception information as a string.
     |      
     |      This default implementation just uses
     |      traceback.print_exception()
     |  
     |  formatMessage(self, record)
     |  
     |  formatStack(self, stack_info)
     |      This method is provided as an extension point for specialized
     |      formatting of stack information.
     |      
     |      The input data is a string as returned from a call to
     |      :func:`traceback.print_stack`, but with the last trailing newline
     |      removed.
     |      
     |      The base implementation just returns the value passed in.
     |  
     |  formatTime(self, record, datefmt=None)
     |      Return the creation time of the specified LogRecord as formatted text.
     |      
     |      This method should be called from format() by a formatter which
     |      wants to make use of a formatted time. This method can be overridden
     |      in formatters to provide for any specific requirement, but the
     |      basic behaviour is as follows: if datefmt (a string) is specified,
     |      it is used with time.strftime() to format the creation time of the
     |      record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used.
     |      The resulting string is returned. This function uses a user-configurable
     |      function to convert the creation time to a tuple. By default,
     |      time.localtime() is used; to change this for a particular formatter
     |      instance, set the 'converter' attribute to a function with the same
     |      signature as time.localtime() or time.gmtime(). To change it for all
     |      formatters, for example if you want all logging times to be shown in GMT,
     |      set the 'converter' attribute in the Formatter class.
     |  
     |  usesTime(self)
     |      Check if the format uses the creation time of the record.
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from logging.Formatter:
     |  
     |  converter = localtime(...)
     |      localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
     |                                tm_sec,tm_wday,tm_yday,tm_isdst)
     |      
     |      Convert seconds since the Epoch to a time tuple expressing local time.
     |      When 'seconds' is not passed in, convert the current time instead.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from logging.Formatter:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from logging.Formatter:
     |  
     |  default_msec_format = '%s,%03d'
     |  
     |  default_time_format = '%Y-%m-%d %H:%M:%S'

FUNCTIONS
    configure_logging(fmt='[{asctime:s@888}] {levelname:s@XXXXXX} {message:s}', style='{', datefmt='%Y-%m-%d %H:%M:%S', color_char='@', output_type='ansi', level_color_placeholder='XXXXXX', level_colors=None, **kwargs)
        A wrapper around logging.basicConfig to configure colorized message logging.
        In addition to the argument accepted by that function, the following are
        also supported.
        
        fmt:
            The format string. This replaces the "format" argument for basicConfig.
        
        color_char:
            The custom format character for color codes in the chosen style.
        
        output_type:
            The output type. It must be one of the types supported by ColorizedText,
            or the custom type 'tty_ansi'. If the value is 'tty_ansi' then the
            output type will be set to 'ansi' for StreamHandlers without output
            streams that are TTYs, otherwise plain.
        
        level_color_placeholder:
            A placeholder string for the log-level-specific color. This will be
            replaced by the appropriate log level hexadecimal color string.
        
        level_colors:
            A map of logging levels to hexadecimal colors. These will be used to
            replace the value of "level_color_placeholder" in the format string for
            each level-specific formatter.
    
    run_example()
        Print some colored logging messages.

DATA
    LEVEL_COLORS = {10: '00a0ff', 20: '00ff00', 30: 'ffff00', 40: 'ff0000'...

colorsysplus.text

NAME
    colorsysplus.text - Handle text colors in different output formats (ANSI, HTML, BBCode, etc.).

CLASSES
    builtins.object
        ColorizedText
    
    class ColorizedText(builtins.object)
     |  ColorizedText(chunks=None, query_term_rgb=False)
     |  
     |  Colorized text stored as a list of (RGB, text) tuples, where RGB is a 3-tuple
     |  of RGB values in the range 0-1.
     |  
     |  Colorized text can be converted to multiple formats.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, chunks=None, query_term_rgb=False)
     |      chunks:
     |        An iterable of 2-tuples where the first item in each tuple is a 3-tuple
     |        of RGB values in the range of [0,1] and the second item is the string to
     |        color.
     |      
     |      query_term_rgb:
     |        If True, query the true RGB values of the currently set terminal colors.
     |  
     |  __repr__(self)
     |      Return repr(self).
     |  
     |  __str__(self)
     |      Return str(self).
     |  
     |  append(self, rgb, text, merge=False)
     |      Add an RGB code and a chunk of text.
     |      
     |      rgb may be None if the text is not colored, i.e. it should inherit the
     |      default color of its target output.
     |  
     |  clear(self)
     |      Clear chunks.
     |  
     |  from_ansi(self, text)
     |      Parse an ANSI-colored string.
     |  
     |  from_bbcode(self, text)
     |      Parse a BBCode string.
     |  
     |  from_html(self, text)
     |      Parse an HTML string.
     |  
     |  from_plain(self, text)
     |      Parse plain text without any colors. This will insert all of the text
     |      into a single chunk without color.
     |  
     |  from_x(self, typ, text)
     |      Parse the given type. It should be listed in TYPES.
     |  
     |  from_xonotic(self, text)
     |      Parse a Xonotic string.
     |  
     |  maybe_load_term_colors(self, force=False)
     |      Load terminal color RGB values.
     |  
     |  reduce(self)
     |      Merge superfluous chunks.
     |  
     |  to_ansi(self)
     |      Generate an ANSI-colored string.
     |  
     |  to_bbcode(self)
     |      Generate a BBCode string.
     |  
     |  to_html(self)
     |      Generate an HTML string.
     |  
     |  to_plain(self)
     |      Generate a plain text string without colors.
     |  
     |  to_x(self, typ)
     |      Convert to the given type. It should be listed in TYPES.
     |  
     |  to_xonotic(self, prefix=False, suffix=False, abbreviate=True)
     |      Generate a Xonotic string.
     |      
     |      prefix: If True, "^7" will be added to the beginning of strings that do not
     |      begin with a color code.
     |      
     |      suffix: If True, "^7" will be added to the end of the string if it contains
     |      any color codes.
     |      
     |      abbreviate: Use color code abbreviations where possible (e.g. "^1" for
     |      "^xf00")
     |      
     |      The defaults for prefix and suffix may change. Do not rely on them.
     |  
     |  update(self, chunks)
     |      Update the object with new text.colorsysplus
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  TYPES = {'ansi': 'ANSI SGR sequences', 'bbcode': 'BB forum code', 'htm...

FUNCTIONS
    apply_gradient(func, text, *args, **kwargs)
        Apply a gradient to a string and return chunks for ColorizedText.
        
        The function should accept a float in the range [0.0, 1.0] indicating the
        relative position in the string for which a color should be returned. args and
        kwargs will be passed as additional arguments to the function.
    
    get_linear_gradient_func(grad)
        Return a function that accepts a numerical value in the range [0,1] and
        returns an RGB value corresponding to a point along a multicolored linear
        gradient.
        
        grad:
          A list or tuple of RGB tuples that define the gradient. The values are
          assumed to be evently spaced.
    
    print_example()
        Print an example to stdout.

DATA
    ANSI_SGR_REGEX = re.compile('(\x1b\\[.+?m)')
Contact
echo xyne.archlinux.org | sed 's/\./@/'
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0