Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-117225: Move colorize functionality to own internal module#118283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 5 commits intopython:mainfromhugovk:doctest-refactor-colorize
May 1, 2024
Merged
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Precompute stubbed ANSIColors with no colours
  • Loading branch information
@hugovk
hugovk committedApr 26, 2024
commit005e44e2da86dd0dc3334f8f731961cfc248609b
18 changes: 9 additions & 9 deletionsLib/_colorize.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,18 +17,18 @@ class ANSIColors:
YELLOW = "\x1b[33m"


def get_colors(colorize: bool = False) -> ANSIColors:
if colorize or can_colorize():
return ANSIColors()
NoColors = ANSIColors()

ansi_colors = ANSIColors()
for attr in dir(NoColors):
if not attr.startswith("__"):
setattr(NoColors, attr, "")

# Set color attributes to empty strings
for attr in dir(ansi_colors):
if not attr.startswith("__"):
setattr(ansi_colors, attr, "")

return ansi_colors
def get_colors(colorize: bool = False) -> ANSIColors:
if colorize or can_colorize():
return ANSIColors()
else:
return NoColors


def can_colorize() -> bool:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp