# Module `src.logger.colors`

Onionr - Private P2P Communication

class to access ANSI control codes

Expand source code

    '''
        Onionr - Private P2P Communication

        class to access ANSI control codes
    '''
    '''
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <https://www.gnu.org/licenses/>.
    '''
    import re
    class Colors:
        '''
            This class allows you to set the color if ANSI codes are supported
        '''
        reset='\033[0m'
        bold='\033[01m'
        disable='\033[02m'
        underline='\033[04m'
        reverse='\033[07m'
        strikethrough='\033[09m'
        invisible='\033[08m'
        italics='\033[3m'
        class fg:
            black='\033[30m'
            red='\033[31m'
            green='\033[32m'
            orange='\033[33m'
            blue='\033[34m'
            purple='\033[35m'
            cyan='\033[36m'
            lightgrey='\033[37m'
            darkgrey='\033[90m'
            lightred='\033[91m'
            lightgreen='\033[92m'
            yellow='\033[93m'
            lightblue='\033[94m'
            pink='\033[95m'
            lightcyan='\033[96m'
        class bg:
            black='\033[40m'
            red='\033[41m'
            green='\033[42m'
            orange='\033[43m'
            blue='\033[44m'
            purple='\033[45m'
            cyan='\033[46m'
            lightgrey='\033[47m'
        @staticmethod
        def filter(data):
            return re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]').sub('', str(data))

## Classes

`class Colors`

  This class allows you to set the color if ANSI codes are supported

  Expand source code

      class Colors:
          '''
              This class allows you to set the color if ANSI codes are supported
          '''
          reset='\033[0m'
          bold='\033[01m'
          disable='\033[02m'
          underline='\033[04m'
          reverse='\033[07m'
          strikethrough='\033[09m'
          invisible='\033[08m'
          italics='\033[3m'
          class fg:
              black='\033[30m'
              red='\033[31m'
              green='\033[32m'
              orange='\033[33m'
              blue='\033[34m'
              purple='\033[35m'
              cyan='\033[36m'
              lightgrey='\033[37m'
              darkgrey='\033[90m'
              lightred='\033[91m'
              lightgreen='\033[92m'
              yellow='\033[93m'
              lightblue='\033[94m'
              pink='\033[95m'
              lightcyan='\033[96m'
          class bg:
              black='\033[40m'
              red='\033[41m'
              green='\033[42m'
              orange='\033[43m'
              blue='\033[44m'
              purple='\033[45m'
              cyan='\033[46m'
              lightgrey='\033[47m'
          @staticmethod
          def filter(data):
              return re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]').sub('', str(data))

  ### Class variables

  `var bg`
    Expand source code

        class bg:
            black='\033[40m'
            red='\033[41m'
            green='\033[42m'
            orange='\033[43m'
            blue='\033[44m'
            purple='\033[45m'
            cyan='\033[46m'
            lightgrey='\033[47m'

  `var bold`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var disable`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var fg`
    Expand source code

        class fg:
            black='\033[30m'
            red='\033[31m'
            green='\033[32m'
            orange='\033[33m'
            blue='\033[34m'
            purple='\033[35m'
            cyan='\033[36m'
            lightgrey='\033[37m'
            darkgrey='\033[90m'
            lightred='\033[91m'
            lightgreen='\033[92m'
            yellow='\033[93m'
            lightblue='\033[94m'
            pink='\033[95m'
            lightcyan='\033[96m'

  `var invisible`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var italics`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var reset`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var reverse`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var strikethrough`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  `var underline`

    str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

    Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

  ### Static methods

  `def filter(data)`
    Expand source code

        @staticmethod
        def filter(data):
            return re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]').sub('', str(data))