Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

We are MicroSoft. You will be assimilated. Resistance is futile. (Attributed to B.G., Gill Bates)


devel / comp.lang.python / Re: How to Add ANSI Color to User Response

SubjectAuthor
o Re: How to Add ANSI Color to User ResponsePierre Fortin

1
Re: How to Add ANSI Color to User Response

<mailman.102.1712998224.3468.python-list@python.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25674&group=comp.lang.python#25674

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pf@pfortin.com (Pierre Fortin)
Newsgroups: comp.lang.python
Subject: Re: How to Add ANSI Color to User Response
Date: Sat, 13 Apr 2024 02:18:07 -0400
Lines: 42
Message-ID: <mailman.102.1712998224.3468.python-list@python.org>
References: <E07728FE-3599-462D-B572-107C5D53C72F@yahoo.com>
<20240410194449.0b2ba78f@pfortin.com>
<b3b4a959-9016-f8bb-81ca-e28a90fe241c@yahoo.no>
<20240413021807.4e35853d@pfortin.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de w+EL1KDyDxESpEd8/dLwRwMgO4S10GHbKvvhDCHJT0Gw==
Cancel-Lock: sha1:qCLEh5BSc/7uBaAem7hfn7mt1vQ= sha256:eC0eNEeSr6qTrDX7gaWE0GyxsuwbzeYb+S2ytTNas5o=
Return-Path: <pf@pfortin.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=pfortin.com header.i=@pfortin.com header.b=rXSJCGqq;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.028
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Add': 0.04;
'+0200': 0.09; 'terminal': 0.09; 'received:173': 0.13; '-*-':
0.16; '2024': 0.16; 'alias': 0.16; 'license:': 0.16; 'mechanisms':
0.16; 'please.': 0.16; 'print(': 0.16; 'python;': 0.16;
'received:144': 0.16; 'subject:User': 0.16; 'updated:': 0.16;
'wrote:': 0.16; 'thu,': 0.19; 'url': 0.19; 'to:addr:python-list':
0.20; "i've": 0.22; 'subject:How': 0.23; 'cc:2**0': 0.25; 'tried':
0.26; 'background': 0.28; 'module': 0.31; 'attach': 0.32; 'python-
list': 0.32; 'skip:2 10': 0.32; 'script': 0.33; 'header:In-Reply-
To:1': 0.34; 'applying': 0.36; "skip:' 10": 0.37; 'text': 0.39;
'use': 0.39; 'initial': 0.61; 'inline': 0.61; 'color': 0.62;
'skip:b 10': 0.63; 'skip:# 10': 0.68; 'url-ip:209/8': 0.76;
'life': 0.77; 'esc': 0.84; 'subject:Color': 0.84; 'tiny': 0.84;
'subject:Response': 0.91; 'yours.': 0.91; 'colors': 0.93
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pfortin.com
; s=default;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References
:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=XLOKO2TXpFksAWTE3jK82k4l8z8YBbYui0myzmiHZro=; b=rXSJCGqqr6WatKQiJwi9Jis7GY
QkUy/N8FTW6Yjso9cj4GYMVV3i2ZC80ORGqD9TQr3tmZXam1lhNW/p5XOJphJsv5FU4sC4lGlxG1G
Gb50MhBKkY4hNas9wWU/zhAnrYt7uc4cMgQIol7aSWvbhTwbhI6qPUEgLTZ98S8LRULmzNY9+3WvJ
5vWbSRc+tjd7ZOjLfbiG9VahOiRxL0VMyBtKYxpTdIsdwczbFrnKgCsb9jL6lr1xDp/bKdnpNs7YV
FrHXvqTGei5OW9/241+EFMVHVKJMtDHdGxD0Pw6C0/l0AXNsMiWnEsgUHcmyeLnxqRg6zlkmjYfB9
5gG/PLjw==;
In-Reply-To: <b3b4a959-9016-f8bb-81ca-e28a90fe241c@yahoo.no>
X-Mailer: Claws Mail 4.2.0git67 (GTK 3.24.41; x86_64-pc-linux-gnu)
X-Get-Message-Sender-Via: ecngx348.inmotionhosting.com: authenticated_id:
pf@pfortin.com
X-Authenticated-Sender: ecngx348.inmotionhosting.com: pf@pfortin.com
X-Originating-IP: 198.46.91.127
X-SpamExperts-Domain: ecngx348.inmotionhosting.com
X-SpamExperts-Username: 198.46.91.127
Authentication-Results: servconfig.com; auth=pass
smtp.auth=198.46.91.127@ecngx348.inmotionhosting.com
X-SpamExperts-Outgoing-Class: ham
X-SpamExperts-Outgoing-Evidence: Combined (0.07)
X-Recommended-Action: accept
X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT/DzMnBwjeAynIjs2pqwWo3PUtbdvnXkggZ
3YnVId/Y5jcf0yeVQAvfjHznO7+bT5zrZdyVoOLhYcVso5GiMJOvpCl8L9DTIFp64Frdm8ZYlx5Y
b2RVtz4UaQEmY0XGIU1IWszBtjhxEU9cs2lF+ufl+GZ+x0GrHBvhaESrL6JBQPq2Gb7u1BCYlN7N
u1YChztaVVOgJn2PNduaLM0B6/q8pWCxvgpyiQ0VNnncqQA004fsWGHYDI6AbzQBKJAR4OLjF9Xw
dAYWDjn/kVHhOs3KelipJdMJj0ua1H5H1aGYnKeiqzwpJQJp5aGHp7lTCYoRykvSYultIRa+1jPt
ZEG3c27W/n1W03bCl4b+QLprSH+Z3fv2uvzfCUaw+Rv9x8w0ubqLLiSA8MfttBAnDZIPyEOoXQrn
zEvfwQmqfL0Bh/p1Vc9TVlVXUP/kORHA48uLb5mum9xAXSaS3KKPtTZXWZip9+GhedmPokL8D3vh
vRIhIxQop2tIIdmMb5ju8fKSTwMUHD8nvT6qjZo9eXrf6IupC5RqLj/k6/wmh+zu68PH12Bh87aa
4YfZs104p87OifVovUq7COge14oi3y0trSOIPpeqwlm2NDGXIJ2x7PZbn55Ujlhzc9wezWkMc93H
DpETs7QPrbIYZbInlIFOd5sNd7Ew4vCqOJ9Rk5T+w/cwG6D5j+RwQoPAAJ/dFHUGGWQuIC9L4vxU
EqCyZesA67itsYkE8InfPuq6bGp50qBlkBL2blkAqDWoat5k50W5NPlvKN2aK9n1HHFoMwJeAFBG
pKjL/IINVPmnTCgFrgyZOQD2NLZJTGB++YLbFTKT+qQ/jp8ZtAHfRrYtBIsbPAlbDjazCbhs7qBp
ykynMgM0O0W2SCwY0e+2n+su9AE3PZN2WnX/QUAr66xWwwM3gX7tYXu631Z0AsQ72aXGujJ3mEwJ
Rrh80xHY0xdBa+UgXGFjQjOGvllxchkw4eM+K7TcfwUWDNwZHEwexG2jhuhEQjf02DvD6NbBWC62
Mac3qaBFfCaFoX7lbNqfdmmzAP32bSj3zEOPUc4jAZfIb68NOkem8ZrIsOxSJo9Mgnt4otO0+GIy
xa7mTH5y7mGf
X-Report-Abuse-To: spam@se1-lax1.servconfig.com
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20240413021807.4e35853d@pfortin.com>
X-Mailman-Original-References: <E07728FE-3599-462D-B572-107C5D53C72F@yahoo.com>
<20240410194449.0b2ba78f@pfortin.com>
<b3b4a959-9016-f8bb-81ca-e28a90fe241c@yahoo.no>
 by: Pierre Fortin - Sat, 13 Apr 2024 06:18 UTC

On Thu, 11 Apr 2024 05:00:32 +0200 Gisle Vanem via Python-list wrote:

>Pierre Fortin wrote:
>
>> Over the years, I've tried different mechanisms for applying colors until
>> I got my hands on f-stings; then I created a tiny module with all the
>> colors (cR, cG, etc) which made my life so much simpler (attached).
>
>Attachments are stripped off in this list.
>It would be nice to see this tiny module of yours.
>An URL or attach as inline text please.

#!/bin/python
# -*- mode: python; -*-
# Copyright:
# 2024-Present, Pierre Fortin <pf@pfortin.com>
# License:
# GPLv3 or any later version: https://www.gnu.org/licenses/gpl-3.0.en.html
# Created:
# 2023-11-10 Initial script
# Updated:

# Usage: f"{cR}red text {cG}green text{cO}; colors off"
# or: print( cY, "yellow text", cO )

# VT100 type terminal colors
ESC = "\u001b";
# Foreground Colors
_black = f"{ESC}[30m"; _red = f"{ESC}[31m"; _green = f"{ESC}[32m"; _yellow = f"{ESC}[33m"
_blue = f"{ESC}[34m"; _magenta = f"{ESC}[35m"; _cyan = f"{ESC}[36m"; _white = f"{ESC}[37m"
# Background Colors
_black_ = f"{ESC}[40m"; _red_ = f"{ESC}[41m"; _green_ = f"{ESC}[42m"; _yellow_ = f"{ESC}[43m"
_blue_ = f"{ESC}[44m"; _magenta_ = f"{ESC}[45m"; _cyan_ = f"{ESC}[46m"; _white_ = f"{ESC}[47m"

_off = f"{ESC}[0m"
ANSIEraseLine = '\033[2K\033[1G'
EL = ANSIEraseLine # short alias

# Color abbreviations (shortcuts for f-sting use)
cK=_black; cR=_red; cG=_green; cY=_yellow; cB=_blue; cM=_magenta; cC=_cyan; cW=_white; cO=_off
# background colors; use {cO} to turn off any color
bK=_black_; bR=_red_; bG=_green_; bY=_yellow_; bB=_blue_; bM=_magenta_; bC=_cyan_; bW=_white_

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor