#!/usr/bin/env python
from setuptools import setup
setup(
  name = 'cs.ansi_colour',
  author = 'Cameron Simpson',
  author_email = 'cs@cskk.id.au',
  version = '20220227',
  url = 'https://bitbucket.org/cameron_simpson/css/commits/all',
  description =
    'Convenience functions for ANSI terminal colour sequences [color].',
  long_description =
    ('Convenience functions for ANSI terminal colour sequences [color].\n'    
 '\n'    
 '*Latest release 20220227*:\n'    
 '* New TerminalColors class parsing /etc/terminal-colors.d and honouring '    
 '$*_COLORS.\n'    
 '* New colour_escape(code) to make the escape sequence for a colour code.\n'    
 '* New COLOUR_CODES mapping of known colour names.\n'    
 '\n'    
 'Mapping and function for adding ANSI terminal colour escape sequences\n'    
 'to strings for colour highlighting of output.\n'    
 '\n'    
 '## Function `colour_escape(code)`\n'    
 '\n'    
 'Return the ANSI escape sequence to activate the colour `code`.\n'    
 '`code` may be an `int` or a `str` which indexes `COLOUR_CODES`.\n'    
 '\n'    
 '## Function `colourise(s, colour=None, uncolour=None)`\n'    
 '\n'    
 'Return a string enclosed in colour-on and colour-off ANSI sequences.\n'    
 '\n'    
 '* `colour`: names the desired ANSI colour.\n'    
 '* `uncolour`: may be used to specify the colour-off colour;\n'    
 "  the default is 'normal' (from `NORMAL_COLOUR`).\n"    
 '\n'    
 '## Function `colourise_patterns(s, patterns, default_colour=None)`\n'    
 '\n'    
 'Colourise a string `s` according to `patterns`.\n'    
 '\n'    
 'Parameters:\n'    
 '* `s`: the string.\n'    
 '* `patterns`: a sequence of patterns.\n'    
 '* `default_colour`: if a string pattern has no colon, or starts\n'    
 '  with a colon, use this colour;\n'    
 '  default "cyan" (from `DEFAULT_HIGHLIGHT`).\n'    
 '\n'    
 'Each pattern may be:\n'    
 '* a string of the form "[colour]:regexp"\n'    
 '* a string containing no colon, taken to be a regexp\n'    
 '* a tuple of the form `(colour,regexp)`\n'    
 '* a regexp object\n'    
 '\n'    
 'Returns the string with ANSI colour escapes embedded.\n'    
 '\n'    
 '## Function `env_no_color(environ=None)`\n'    
 '\n'    
 'Test the `$NO_COLOR` environment variable per the specification at\n'    
 'https://no-color.org/\n'    
 '\n'    
 '## Function `make_pattern(pattern, default_colour=None)`\n'    
 '\n'    
 'Convert a `pattern` specification into a `(colour,regexp)` tuple.\n'    
 '\n'    
 'Parameters:\n'    
 '* `pattern`: the pattern to parse\n'    
 '* `default_colour`: the highlight colour,\n'    
 '  default "cyan" (from `DEFAULT_HIGHLIGHT`).\n'    
 '\n'    
 'Each `pattern` may be:\n'    
 '* a string of the form "[colour]:regexp"\n'    
 '* a string containing no colon, taken to be a regexp\n'    
 '* a tuple of the form `(colour,regexp)`\n'    
 '* a regexp object\n'    
 '\n'    
 '## Function `make_patterns(patterns, default_colour=None)`\n'    
 '\n'    
 'Convert an iterable of pattern specifications into a list of\n'    
 '`(colour,regexp)` tuples.\n'    
 '\n'    
 'Parameters:\n'    
 '* `patterns`: an iterable of patterns to parse\n'    
 '* `default_colour`: the highlight colour,\n'    
 '  default "cyan" (from `DEFAULT_HIGHLIGHT`).\n'    
 '\n'    
 'Each pattern may be:\n'    
 '* a string of the form "[colour]:regexp"\n'    
 '* a string containing no colon, taken to be a regexp\n'    
 '* a tuple of the form (colour, regexp)\n'    
 '* a regexp object\n'    
 '\n'    
 '## Class `TerminalColors`\n'    
 '\n'    
 "A parser for `/etc/terminal-colors.d'` files.\n"    
 '\n'    
 '*Method `TerminalColors.__init__(self, util_name=None, term_name=None, '    
 'type_name=None, colors_dirpath=None, envvar=None)`*:\n'    
 'Initialise the `TerminalColors` instance.\n'    
 '\n'    
 'Parameters:\n'    
 '* `util_name`: optional utility name, default from `sys.argv[0]`\n'    
 '* `term_name`: optional terminal name, default from the `$TERM` envvar\n'    
 "* `type_name`: optional type name, default `'enable'`\n"    
 '* `colors_dirpath`: optional specification files directory path,\n'    
 '  default from `TerminalColors.TERMINAL_COLORS_D`\n'    
 '* `envvar`: environment variable to override matches;\n'    
 "  the default `util_name+'_COLORS'`,\n"    
 "  thus `$LS_COLORS` if `util_name=='ls'`.\n"    
 '  That may be the value `False` if no environment variable should be an '    
 'override.\n'    
 '\n'    
 '*Method `TerminalColors.convert_sequence(sequence)`*:\n'    
 'Convert a colour specification to an escape sequence.\n'    
 '\n'    
 '*Method `TerminalColors.find_specfile(self)`*:\n'    
 'Locate the most specific specification file matching our criteria.\n'    
 'Return `None` if no file matches.\n'    
 '\n'    
 '*Property `TerminalColors.mapping`*:\n'    
 'The mapping of `name` to escape sequence.\n'    
 '\n'    
 '*Method `TerminalColors.scan(self, path=None)`*:\n'    
 'Scan the colour specification in `path`\n'    
 'and yield `(name,escape_sequence)` tuples.\n'    
 '\n'    
 '# Release Log\n'    
 '\n'    
 '\n'    
 '\n'    
 '*Release 20220227*:\n'    
 '* New TerminalColors class parsing /etc/terminal-colors.d and honouring '    
 '$*_COLORS.\n'    
 '* New colour_escape(code) to make the escape sequence for a colour code.\n'    
 '* New COLOUR_CODES mapping of known colour names.\n'    
 '\n'    
 '*Release 20200729*:\n'    
 '* New env_no_color() test function honouring the $NO_COLOUR envvar per '    
 'https://no-color.org/\n'    
 '* colourise: get the "normal" default from the global NORMAL_COLOUR.\n'    
 '\n'    
 '*Release 20180726*:\n'    
 'greater markdowning of docstrings\n'    
 '\n'    
 '*Release 20180725.2*:\n'    
 'some markdown, still release testing\n'    
 '\n'    
 '*Release 20180725.1*:\n'    
 'Trivial changes, testing release process.\n'    
 '\n'    
 '*Release 20180725*:\n'    
 'rename second colourise function to colourise_patterns, was shadowing '    
 'things\n'    
 '\n'    
 '*Release 20180422*:\n'    
 '* New function colourise to colour strings with regexp matches.\n'    
 '* New helper functions make_pattern and make_patterns to construct (colour, '    
 'regexp)s from specifications.\n'    
 '* New public names NORMAL_COLOUR and DEFAULT_HIGHLIGHT.\n'    
 '\n'    
 '*Release 20170902*:\n'    
 'Release metadata changes.\n'    
 '\n'    
 '*Release 20160828*:\n'    
 'Add PyPI category, other minor tweaks.\n'    
 '\n'    
 '*Release 20150112*:\n'    
 'PyPI release.\n'    
 '\n'    
 '*Release 20150107*:\n'    
 'first standalone pypi release'),
  install_requires = ['cs.gimmicks'],
  classifiers = ['Development Status :: 6 - Mature', 'Environment :: Console', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Terminals', 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)'],
  keywords = ['python2', 'python3'],
  license = 'GNU General Public License v3 or later (GPLv3+)',
  long_description_content_type = 'text/markdown',
  package_dir = {'': 'lib/python'},
  py_modules = ['cs.ansi_colour'],
)
