Skip to content

Commit

Permalink
use strip_color from ansicolors package
Browse files Browse the repository at this point in the history
  • Loading branch information
mbektas committed Apr 4, 2024
1 parent 1af5ae5 commit 0409031
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
19 changes: 1 addition & 18 deletions papermill/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import re
from colors import strip_color


class AwsError(Exception):
Expand Down Expand Up @@ -78,20 +78,3 @@ def missing_dep():
)

return missing_dep


# copied from https://github.com/jonathaneunice/ansiwrap/blob/master/ansiwrap/core.py
# papermill used to use strip_color from ansiwrap package, but removed due to dependency
# resolution issues (ref: https://github.com/nteract/papermill/pull/681)
def strip_color(s):
"""
Remove ANSI color/style sequences from a string. The set of all
possibly ANSI sequences is large, so does not try to strip every
possible one. But does strip some outliers seen not just in text
generated by this module, but by other ANSI colorizers in the wild.
Those include `\x1b[K` (aka EL or erase to end of line) and `\x1b[m`
a terse version of the more common `\x1b[0m`.
"""
ANSIRE = re.compile('\x1b\\[(K|.*?m)')

return ANSIRE.sub('', s)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ requests
entrypoints
tenacity >= 5.0.2
aiohttp >=3.9.0; python_version=="3.12"
ansicolors

0 comments on commit 0409031

Please sign in to comment.