Debian Codegraph @

tests/trb_hebrew.py

raw symbols SCIP
1 """Creates a version of traceback_es.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 LANG = "he"
28 friendly_traceback.install()
29 friendly_traceback.set_lang(LANG)
30 friendly_traceback.set_formatter("docs")
31
32 sys.path.insert(0, this_dir)
33 py_version = f"{sys.version_info.major}.{sys.version_info.minor}"
34
35 import trb_common
36
37 target = os.path.normpath(
38 os.path.join(docs_root_dir, f"source/tracebacks_{LANG}.rst")
39 )
40
41 intro_text = """
42 Friendly tracebacks - בעברית
43 ======================================
44
45 Friendly שואפת לספק משוב ידידותי יותר כאשר מדובר בחריג
46 מוגדל ממה שנעשה על ידי Python.
47 (sentence translated by Google Translate).
48
49 Below, we can find some examples. SyntaxError cases, as well as TabError and
50 IndentationError cases, are shown in a separate page.
51 Not all cases handled by friendly are included here.
52
53 .. note::
54
55 The content of this page is generated by running
56 `{name}` located in the ``tests/`` directory.
57 This needs to be done explicitly, independently of updating the
58 documentation using Sphinx.
59
60 Friendly-traceback version: {friendly}
61 Python version: {python}
62
63 """.format(
64 friendly=friendly_traceback.__version__,
65 python=platform.python_version(),
66 name=sys.argv[0],
67 )
68
69 print(f"Python version: {platform.python_version()}; Hebrew")
70
71 trb_common.create_tracebacks(target, intro_text)