Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
fail-fast: false
max-parallel: 8
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13, 3.14]
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- os: ubuntu-22.04
python-version: 3.7

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Setup build and test environment
Expand Down Expand Up @@ -54,10 +54,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python 3.12
if: startsWith(github.event.ref, 'refs/tags')
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Build Package
Expand Down
14 changes: 6 additions & 8 deletions colorful/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import os
Expand All @@ -34,7 +32,7 @@ class ColorfulModule(types.ModuleType):
this module.
"""
def __init__(self, colorful, *args):
super(ColorfulModule, self).__init__(*args)
super().__init__(*args)
self.colorful = colorful

@contextmanager
Expand Down
12 changes: 5 additions & 7 deletions colorful/ansi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import math
Expand Down
16 changes: 7 additions & 9 deletions colorful/colors.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import json
Expand Down Expand Up @@ -41,7 +39,7 @@ def parse_rgb_txt_file(path):
#: Holds the generated color dict
color_dict = {}

with open(path, 'r') as rgb_txt:
with open(path) as rgb_txt:
for line in rgb_txt:
line = line.strip()
if not line or line.startswith('!'):
Expand All @@ -64,7 +62,7 @@ def parse_json_color_file(path):

:param str path: the path to the JSON color file
"""
with open(path, "r") as color_file:
with open(path) as color_file:
color_list = json.load(color_file)

# transform raw color list into color dict
Expand Down
26 changes: 12 additions & 14 deletions colorful/core.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import os
Expand Down Expand Up @@ -88,7 +86,7 @@ def translate_rgb_to_ansi_code(red, green, blue, offset, colormode):
end_code = ansi.ANSI_ESCAPE_CODE.format(code=offset + ansi.COLOR_CLOSE_OFFSET)
return start_code, end_code

raise ColorfulAttributeError('invalid color mode "{0}"'.format(colormode))
raise ColorfulAttributeError('invalid color mode "{}"'.format(colormode))


def translate_colorname_to_ansi_code(colorname, offset, colormode, colorpalette):
Expand All @@ -108,7 +106,7 @@ def translate_colorname_to_ansi_code(colorname, offset, colormode, colorpalette)
try:
red, green, blue = colorpalette[colorname]
except KeyError:
raise ColorfulAttributeError('the color "{0}" is unknown. Use a color in your color palette (by default: X11 rgb.txt)'.format( # noqa
raise ColorfulAttributeError('the color "{}" is unknown. Use a color in your color palette (by default: X11 rgb.txt)'.format( # noqa
colorname))
else:
return translate_rgb_to_ansi_code(red, green, blue, offset, colormode)
Expand All @@ -132,7 +130,7 @@ def resolve_modifier_to_ansi_code(modifiername, colormode):
try:
start_code, end_code = ansi.MODIFIERS[modifiername]
except KeyError:
raise ColorfulAttributeError('the modifier "{0}" is unknown. Use one of: {1}'.format(
raise ColorfulAttributeError('the modifier "{}" is unknown. Use one of: {}'.format(
modifiername, ansi.MODIFIERS.keys()))
else:
return ansi.ANSI_ESCAPE_CODE.format(
Expand Down Expand Up @@ -222,7 +220,7 @@ def style_string(string, ansi_style, colormode, nested=False):
nest_ph=ansi.NEST_PLACEHOLDER if nested else '')


class ColorfulString(object):
class ColorfulString():
"""
Represents a colored string
"""
Expand Down Expand Up @@ -301,7 +299,7 @@ def __getattr__(self, name):
return str_method


class Colorful(object):
class Colorful():
"""
Provides methods to style strings for terminal
output.
Expand Down Expand Up @@ -443,7 +441,7 @@ def use_style(self, style_name):
try:
style = getattr(styles, style_name.upper())
except AttributeError:
raise ColorfulError('the style "{0}" is undefined'.format(
raise ColorfulError('the style "{}" is undefined'.format(
style_name))
else:
self.colorpalette = style
Expand Down Expand Up @@ -493,7 +491,7 @@ def print(self, *objects, sep=' ', end='\n', file=None, flush=False):
styled_objects = [self.format(o) for o in objects]
print(*styled_objects, sep=sep, end=end, file=file, flush=flush)

class ColorfulStyle(object):
class ColorfulStyle():
"""
Represents a colorful style
"""
Expand Down
12 changes: 5 additions & 7 deletions colorful/styles.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""


Expand Down
12 changes: 5 additions & 7 deletions colorful/terminal.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import sys
Expand Down
12 changes: 5 additions & 7 deletions colorful/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""
import re

Expand Down
12 changes: 5 additions & 7 deletions examples/colors.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import sys
Expand Down
12 changes: 5 additions & 7 deletions examples/monokai.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import sys
Expand Down
12 changes: 5 additions & 7 deletions examples/solarized.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import sys
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import ast
Expand All @@ -25,7 +23,7 @@

if sys.version_info[0:2] in EXPL_NOT_SUPPORTED_VERSIONS:
raise SystemExit("colorful does explicitly not support the following python versions "
"due to big incompatibilities: {0}".format(EXPL_NOT_SUPPORTED_VERSIONS))
"due to big incompatibilities: {}".format(EXPL_NOT_SUPPORTED_VERSIONS))


#: Holds the root dir for the project.
Expand Down Expand Up @@ -107,6 +105,7 @@ def read_version():
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
Expand Down
12 changes: 5 additions & 7 deletions tests/test_ansi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import os
Expand Down
12 changes: 5 additions & 7 deletions tests/test_colors.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

"""
colorful
~~~~~~~~
colorful
~~~~~~~~

Terminal string styling done right, in Python.
Terminal string styling done right, in Python.

:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
:copyright: (c) 2017 by Timo Furrer <[email protected]>
:license: MIT, see LICENSE for more details.
"""

import os
Expand Down
Loading
Loading