-
We've had 2 discussions where I disagreed that things should be warnings. Is there a way for me in my |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Alas, no, I can't think of an easy way to do this without modifying the status code. That said, one or maybe both of the warnings could be reworded and/or downgraded to plain status messages, which would maybe take away some large part of the annoyance for you? |
Beta Was this translation helpful? Give feedback.
-
I made such a solution now by monkeypatching: STATUS_PATTERNS_BY_FORCED_PRIORITY = {
-1: ( # Priority of `-1` means to drop the message completely
re.compile(r'^sampling [0-9]+ rows$'),
),
0: (
re.compile(r'guessed "dir" filetype based on contents'),
),
}
# Monkeypatching `vd.status` to filter some messages to a lower priority:
@VisiData.api
def status(vd: VisiData, *args, priority: int = 0) -> bool:
'Display *args* on status until next action.'
if not args:
return True
### Forcing different priority on some messages: ###############################################
# #
messages = tuple(map(str, args))
for message in messages:
for forced_priority, patterns in STATUS_PATTERNS_BY_FORCED_PRIORITY.items():
for pattern in patterns:
if pattern.match(message):
priority = min(priority, forced_priority)
if priority < 0:
return False
k = (priority, messages)
# #
### Finished forcing different priority on some messages. ######################################
vd.statuses[k] = vd.statuses.get(k, 0) + 1
source = visidata.statusbar.getStatusSource()
if not vd.cursesEnabled:
msg = '\r' + visidata.statusbar.composeStatus(args)
if vd.options.debug:
msg += f' [{source}]'
builtins.print(msg, file=sys.stderr)
return vd.addToStatusHistory(*args, priority=priority, source=source) |
Beta Was this translation helpful? Give feedback.
Alas, no, I can't think of an easy way to do this without modifying the status code. That said, one or maybe both of the warnings could be reworded and/or downgraded to plain status messages, which would maybe take away some large part of the annoyance for you?