|
1 | | -# -*- coding: utf-8 -*- |
2 | | -from __future__ import absolute_import, division, print_function, unicode_literals |
3 | | - |
4 | 1 | # The MIT License |
5 | 2 |
|
6 | | -# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de |
| 3 | +# Copyright (c) 2017 - 2025 Tammo Ippen, tammo.ippen@posteo.de |
7 | 4 |
|
8 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | 6 | # of this software and associated documentation files (the "Software"), to deal |
|
29 | 26 |
|
30 | 27 |
|
31 | 28 | def main(): |
32 | | - print(color('Do not print colors, if `no_color` is set to True', fg='red', no_color=True)) |
33 | | - print(color('You can set a foreground', fg='red')) |
34 | | - print(color('and a background.', bg='red')) |
35 | | - print(color('Or both.', fg='black', bg='cyan')) |
36 | | - |
37 | | - print(color('Aside from 4-bit / name colors', fg='green', mode='names')) |
38 | | - print(color('you can also set 8-bit colors / 256-color lookup tables', fg=126, bg=87, mode='byte')) |
39 | | - print(color('or go with full 24-bit rgb colors', fg=(50, 50, 50), bg=(166, 237, 240), mode='rgb')) |
40 | | - |
41 | | - no_color = os.environ.get('NO_COLOR') |
42 | | - os.environ['NO_COLOR'] = '1' |
43 | | - print(color('The Environment variable `NO_COLOR` will always strip colors.', fg='red')) |
| 29 | + print( |
| 30 | + color( |
| 31 | + "Do not print colors, if `no_color` is set to True", fg="red", no_color=True |
| 32 | + ) |
| 33 | + ) |
| 34 | + print(color("You can set a foreground", fg="red")) |
| 35 | + print(color("and a background.", bg="red")) |
| 36 | + print(color("Or both.", fg="black", bg="cyan")) |
| 37 | + |
| 38 | + print(color("Aside from 4-bit / name colors", fg="green", mode="names")) |
| 39 | + print( |
| 40 | + color( |
| 41 | + "you can also set 8-bit colors / 256-color lookup tables", |
| 42 | + fg=126, |
| 43 | + bg=87, |
| 44 | + mode="byte", |
| 45 | + ) |
| 46 | + ) |
| 47 | + print( |
| 48 | + color( |
| 49 | + "or go with full 24-bit rgb colors", |
| 50 | + fg=(50, 50, 50), |
| 51 | + bg=(166, 237, 240), |
| 52 | + mode="rgb", |
| 53 | + ) |
| 54 | + ) |
| 55 | + |
| 56 | + no_color = os.environ.get("NO_COLOR") |
| 57 | + os.environ["NO_COLOR"] = "1" |
| 58 | + print( |
| 59 | + color("The Environment variable `NO_COLOR` will always strip colors.", fg="red") |
| 60 | + ) |
44 | 61 | if no_color: |
45 | | - os.environ['NO_COLOR'] = no_color |
| 62 | + os.environ["NO_COLOR"] = no_color |
46 | 63 | else: |
47 | | - os.environ.pop('NO_COLOR') |
48 | | - |
49 | | - force_color = os.environ.get('FORCE_COLOR') |
50 | | - os.environ['FORCE_COLOR'] = '1' |
51 | | - print(color('The Environment variable `FORCE_COLOR` allows to toggle colors,', fg='blue')) |
52 | | - os.environ['FORCE_COLOR'] = '0' |
53 | | - print(color('setting it to 0, none or false, strips color codes', fg='magenta')) |
54 | | - os.environ['FORCE_COLOR'] = '1' |
55 | | - print(color('everything else forces color codes', fg='green')) |
| 64 | + os.environ.pop("NO_COLOR") |
| 65 | + |
| 66 | + force_color = os.environ.get("FORCE_COLOR") |
| 67 | + os.environ["FORCE_COLOR"] = "1" |
| 68 | + print( |
| 69 | + color( |
| 70 | + "The Environment variable `FORCE_COLOR` allows to toggle colors,", fg="blue" |
| 71 | + ) |
| 72 | + ) |
| 73 | + os.environ["FORCE_COLOR"] = "0" |
| 74 | + print(color("setting it to 0, none or false, strips color codes", fg="magenta")) |
| 75 | + os.environ["FORCE_COLOR"] = "1" |
| 76 | + print(color("everything else forces color codes", fg="green")) |
56 | 77 | if force_color: |
57 | | - os.environ['FORCE_COLOR'] = force_color |
| 78 | + os.environ["FORCE_COLOR"] = force_color |
58 | 79 | else: |
59 | | - os.environ.pop('FORCE_COLOR') |
| 80 | + os.environ.pop("FORCE_COLOR") |
60 | 81 |
|
61 | 82 |
|
62 | | -if __name__ == '__main__': |
| 83 | +if __name__ == "__main__": |
63 | 84 | main() |
0 commit comments