sonntagsgesicht/auxilium

View on GitHub
auxilium/tools/const.py

Summary

Maintainability
A
25 mins
Test Coverage
# -*- coding: utf-8 -*-

# auxilium
# --------
# Python project for an automated test and deploy toolkit.
#
# Author:   sonntagsgesicht
# Version:  0.2.8, copyright Friday, 14 January 2022
# Website:  https://github.com/sonntagsgesicht/auxilium
# License:  Apache License 2.0 (see LICENSE file)


from os import name as os_name
from os.path import basename, join, normpath
from sys import executable

PYTHON = basename(executable)
REPLACE = ":()-*.#/\\'?!<>" + '"'
DEMO_PATH = "auxilium_demo"
PROFILE_PATH = "dev.py"
TEST_PATH = normpath('test/')

AUX_PATH = '.aux'
LAST_M_FILE = join(AUX_PATH, 'last.json')
CONFIG_PATH = join(AUX_PATH, 'config')
VENV_PATH = join(AUX_PATH, 'venv')

FREEZE_FILE = join(AUX_PATH, '.freeze')
TEMP_REMOVE_FILE = join(AUX_PATH, '.site_packages_to_remove')

GIT_PATH = '.git'

if os_name == 'nt':
    VENV_TAIL = join('Scripts', PYTHON)
    VENV = join(VENV_PATH, VENV_TAIL)
elif os_name == 'posix':
    VENV_TAIL = join('bin', PYTHON)
    VENV = join(VENV_PATH, VENV_TAIL)
else:
    VENV_TAIL = ''
    VENV = PYTHON

DETAIL_FORMATTER = '%(levelname)-7.7s  %(message)s'
MINIMAL_FORMATTER = ' %(message)s'
TEST_LOG_FORMATTER = 'โ€ข' + MINIMAL_FORMATTER

VERBOSITY_LEVELS = (
    (20, MINIMAL_FORMATTER),
    (0, MINIMAL_FORMATTER),
    (10, MINIMAL_FORMATTER),
    (20, DETAIL_FORMATTER),
    (30, DETAIL_FORMATTER),
    (40, DETAIL_FORMATTER),
    (50, DETAIL_FORMATTER)
    )

SUB_FORMATTER_PREFIX = '|'


_ICONS = {
    # basic
    'ok': 'โœ…',
    'cancel': 'โŒ',
    # log level
    'debug': '๐Ÿชฒ',
    'info': 'โ„น๏ธ',
    'warn': 'โœ‹',
    'warning': 'โœ‹',
    'error': '๐Ÿšซ',
    # git
    'init': '๐Ÿฃ',
    'clone': '๐Ÿงช',
    'branch': '๐Ÿ“ฆ',
    'checkout': '๐Ÿ”˜',
    'add': 'โž•',
    'missing': '๐Ÿคท',
    'status': '๐Ÿ”„',
    'commit': '๐Ÿ“Œ',
    'tag': '๐Ÿท',
    'pull': '๐Ÿ“ฅ',
    'push': '๐Ÿ“ค',
    # commands
    'python': '๐Ÿ',
    'run': '๐Ÿ‘Ÿ',
    'demo': '๐Ÿน',
    'uninstall': '๐Ÿ’”',
    'clean': '๐Ÿงน',
    'finish': '๐Ÿ',
    # create
    'create': '๐Ÿชš',
    'setup': '๐Ÿงฐ',  # 'โš™๏ธ',
    'install': '๐Ÿ—œ',
    'venv': '๐Ÿ‘ป',
    # update
    'maintenance': '๐Ÿ› ',
    'upgrade': '๐Ÿ…',
    # test
    'test': 'โ›‘',
    'quality': '๐Ÿ”',
    'security': '๐Ÿšจ',
    'inspect': '๐Ÿ•ถ',
    'coverage': '๐Ÿ“‘',
    'profile': 'โฑ',
    # doc
    'apidoc': 'โœ๏ธ',
    'html': '๐ŸŒ',
    'single': '๐Ÿชง',
    'epub': '๐Ÿ“•',
    'latex': '๐Ÿ“’',
    'pdf': '๐Ÿ“—',
    'show': '๐Ÿ’ก',
    # build
    'build': '๐Ÿ—',
    'archive': '๐Ÿ—œ',
    'deploy': '๐Ÿ›ซ',
}


class IconContainer(dict):
    none = ''
    default = '*'
    length = 3, 1

    def __getitem__(self, item):
        item = item.lower()
        if super(IconContainer, self).__contains__(item):
            value = super(IconContainer, self).__getitem__(item)
            if value is None:
                value = ''
        elif not item:
            value = ''
        else:
            value = '*'
        length, pre = self.__class__.length
        value = value.ljust(length if len(value.encode()) < 4 else length-1)
        return ' ' * pre + value


ICONS = IconContainer(_ICONS)