Debian Codegraph @

tests/trb_french.py

raw symbols SCIP
1 """Creates a version of traceback_fr.rst to insert in the documentation.
2 """
3
4 # When creating a new translation, you need to:
5 # 1. Make a copy of this file
6 # 2. Change the value of LANG as well as 'intro_text' so that they reflect the
7 # appropriate language
8 # 3. Change the first line of this file so that the name of the rst file
9 # is correct!
10
11
12 import os
13 import sys
14 import platform
15 this_dir = os.path.dirname(__file__)
16 sys.path.append(os.path.join(this_dir, ".."))
17 import friendly_traceback
18
19
20 # Make it possible to find docs and tests source
21 docs_root_dir = os.path.abspath(
22 os.path.join(this_dir, "..", "..", "friendly-docs")
23 )
24 assert os.path.isdir(docs_root_dir), "Separate docs repo need to exist"
25 sys.path.append(os.path.join(this_dir, ".."))
26
27
28 # sys.path.insert(0, root_dir)
29
30 LANG = "fr"
31 friendly_traceback.install()
32 friendly_traceback.set_lang(LANG)
33 friendly_traceback.set_formatter("docs")
34
35 sys.path.insert(0, this_dir)
36
37
38 import trb_common
39
40 target = os.path.normpath(
41 os.path.join(docs_root_dir, f"source/tracebacks_{LANG}.rst")
42 )
43
44 intro_text = """
45 |france| Friendly tracebacks - en Français
46 ===========================================
47
48 Le but principal de friendly est de fournir des rétroactions plus
49 conviviales que les fameux **tracebacks** de Python lorsqu'une exception survient.
50
51 .. note::
52
53 Le contenu de cette page a été généré par l'exécution de
54 `{name}` situé dans le répertoire ``tests/``.
55 Ceci a besoin d'être fait de manière explicite lorsqu'on veut
56 faire des corrections ou des ajouts, avant de faire la mise
57 à jour du reste de la documentation avec Sphinx.
58
59 Friendly-traceback version: {friendly}
60 Python version: {python}
61
62 """.format(
63 friendly=friendly_traceback.__version__,
64 python=platform.python_version(),
65 name=sys.argv[0],
66 )
67
68 print(f"Python version: {platform.python_version()}; French")
69
70 trb_common.create_tracebacks(target, intro_text)