Weekly backup.

This commit is contained in:
2022-06-04 12:57:39 +02:00
parent e552583393
commit 015b896f65
68 changed files with 3530 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 6cc56ee4-6d42-4d50-beb3-bb22a98298dd
:mtime: 20220130154530
:mtime: 20220528185642
:ctime: 20220130153624
:END:
#+title: textual
@@ -13,6 +13,66 @@ Rich est une librairie Python permettant de :
* Afficher des tables et du contenu markdown,
* Appliquer une coloration synthaxique.
* Howto
** Pour inspecter un objet (/rich.inspect method)
#+BEGIN_SRC python :results output
from rich import inspect
class Dummy:
def __init__(self):
self.a = 'A'
self.b = 123
inspect(vars)
inspect(Dummy())
#+END_SRC
#+RESULTS:
: ╭────────────────── <built-in function vars> ──────────────────╮
: │ def vars(...) │
: │ │
: │ vars([object]) -> dictionary │
: │ │
: │ 29 attribute(s) not shown. Run inspect(inspect) for options. │
: ╰──────────────────────────────────────────────────────────────╯
: ╭────────── <class '__main__.Dummy'> ───────────╮
: │ ╭───────────────────────────────────────────╮ │
: │ │ <__main__.Dummy object at 0x7f55d6d2d7c0> │ │
: │ ╰───────────────────────────────────────────╯ │
: │ │
: │ a = 'A' │
: │ b = 123 │
: ╰───────────────────────────────────────────────╯
** Formatter les logs
#+BEGIN_SRC python :results output
import logging
from rich.logging import RichHandler
FORMAT = "%(message)s"
logging.basicConfig(
level="NOTSET",
format=FORMAT,
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True)])
log = logging.getLogger("rich")
log.info("Logging set up.")
def division(a, b):
log.debug(f"Dividing {a} by {b}.")
try:
return a / b
except ZeroDivisionError:
log.exception("Oh noes!")
division(3, 2)
division(5, 0)
#+END_SRC
#+RESULTS:
* Références
* [[https://github.com/Textualize/textual][Textual - Github]]
* [[https://github.com/Textualize/rich][Rich - Github]]