Debian Codegraph @

tests/trb_syntax_spanish.py

raw symbols SCIP
1 """Creates a version of syntax_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 # Make it possible to find docs and tests source
20 docs_root_dir = os.path.abspath(
21 os.path.join(this_dir, "..", "..", "friendly-docs")
22 )
23 assert os.path.isdir(docs_root_dir), "Separate docs repo need to exist"
24
25 LANG = "es"
26 friendly_traceback.install()
27 friendly_traceback.set_lang(LANG)
28 friendly_traceback.set_formatter("docs")
29
30 sys.path.insert(0, this_dir)
31 py_version = f"{sys.version_info.major}.{sys.version_info.minor}"
32
33 import trb_syntax_common
34
35 target = os.path.normpath(
36 os.path.join(
37 docs_root_dir, f"source/syntax_tracebacks_{LANG}.rst"
38 )
39 )
40
41 intro_text = """
42 Friendly SyntaxError tracebacks - en español
43 =============================================
44
45 Friendly tiene como objetivo proporcionar comentarios más amigables
46 cuando se produce una excepción
47 se plantea que lo que hace Python (sentence translated by Google Translate).
48
49 This file contains only examples of SyntaxError and its sub-classes.
50 Some tests may appear to be repetitive to a human reader
51 but they are may be included to ensure more complete test coverage.
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 On Windows, if Sphinx is installed on your computer, it is suggested
60 instead to run make_trb.bat in the root directory as it will create
61 similar files for all languages *and* update the documentation.
62
63 Friendly-traceback version: {friendly}
64 Python version: {python}
65
66 """.format(
67 friendly=friendly_traceback.__version__,
68 python=platform.python_version(),
69 name=sys.argv[0],
70 )
71
72 print(f"Python version: {platform.python_version()}; Spanish")
73
74 trb_syntax_common.create_tracebacks(target, intro_text)