33# This file is distributed under the same license as the Python package.
44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
6+ # Translators:
7+ # Jarry Shaw <[email protected] >, 20188+ #
69#, fuzzy
710msgid ""
811msgstr ""
912"Project-Id-Version : Python 3.7\n "
1013"Report-Msgid-Bugs-To : \n "
11- "POT-Creation-Date : 2018-06-30 05:56+0900\n "
12- "PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE\n "
14+ "POT-Creation-Date : 2018-10-29 09:36+0900\n "
15+ "PO-Revision-Date : 2017-02-16 17:48+0000\n "
16+ "
Last-Translator :
Jarry Shaw <[email protected] >, 2018\n "
1317"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
1418"MIME-Version : 1.0\n "
1519"Content-Type : text/plain; charset=UTF-8\n "
@@ -19,11 +23,11 @@ msgstr ""
1923
2024#: ../../library/ast.rst:2
2125msgid ":mod:`ast` --- Abstract Syntax Trees"
22- msgstr ""
26+ msgstr ":mod:`ast` --- 抽象语法树 "
2327
2428#: ../../library/ast.rst:10
2529msgid "**Source code:** :source:`Lib/ast.py`"
26- msgstr ""
30+ msgstr "**源代码:** :source:`Lib/ast.py` "
2731
2832#: ../../library/ast.rst:14
2933msgid ""
@@ -32,6 +36,8 @@ msgid ""
3236"with each Python release; this module helps to find out programmatically "
3337"what the current grammar looks like."
3438msgstr ""
39+ ":mod:`ast` 模块帮助 Python 程序处理 Python 语法的抽象语法树。抽象语法或许会随着 Python "
40+ "的更新发布而改变;该模块能够帮助理解当前语法在编程层面的样貌。"
3541
3642#: ../../library/ast.rst:19
3743msgid ""
@@ -42,10 +48,13 @@ msgid ""
4248":class:`ast.AST`. An abstract syntax tree can be compiled into a Python "
4349"code object using the built-in :func:`compile` function."
4450msgstr ""
51+ "抽象语法树可通过向 :func:`compile: 内置函数传递 :data:`ast.PyCF_ONLY_AST` 参数获取,或使用该模块中提供的 "
52+ ":func:`parse` 函数。其返回结果将是一个对象树,其中所有对象均继承自 :class:`ast.AST` 类。抽象语法树可被 "
53+ ":func:`compile: 内置函数编译为 Python 代码对象。"
4554
4655#: ../../library/ast.rst:27
4756msgid "Node classes"
48- msgstr ""
57+ msgstr "节点类 "
4958
5059#: ../../library/ast.rst:31
5160msgid ""
@@ -54,6 +63,8 @@ msgid ""
5463":ref:`below <abstract-grammar>`. They are defined in the :mod:`_ast` C "
5564"module and re-exported in :mod:`ast`."
5665msgstr ""
66+ "这是所有 AST 节点类的基类。实际上,这些节点类派生自:ref:`如下 <abstract-grammar>`释例的 "
67+ ":file:`Parser/Python.asdl` 文件。它们在 C 语言模块 :mod:`_ast` 定义,并被导出至 :mod:`ast` 模块。"
5768
5869#: ../../library/ast.rst:36
5970msgid ""
@@ -66,20 +77,20 @@ msgid ""
6677"abstract: only instances of specific constructor nodes are ever created."
6778msgstr ""
6879
69- #: ../../library/ast.rst:46
80+ #: ../../library/ast.rst:49
7081msgid ""
7182"Each concrete class has an attribute :attr:`_fields` which gives the names "
7283"of all child nodes."
7384msgstr ""
7485
75- #: ../../library/ast.rst:49
86+ #: ../../library/ast.rst:52
7687msgid ""
7788"Each instance of a concrete class has one attribute for each child node, of "
7889"the type as defined in the grammar. For example, :class:`ast.BinOp` "
7990"instances have an attribute :attr:`left` of type :class:`ast.expr`."
8091msgstr ""
8192
82- #: ../../library/ast.rst:53
93+ #: ../../library/ast.rst:56
8394msgid ""
8495"If these attributes are marked as optional in the grammar (using a question "
8596"mark), the value might be ``None``. If the attributes can have zero-or-more"
@@ -88,7 +99,7 @@ msgid ""
8899"compiling an AST with :func:`compile`."
89100msgstr ""
90101
91- #: ../../library/ast.rst:62
102+ #: ../../library/ast.rst:65
92103msgid ""
93104"Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have "
94105":attr:`lineno` and :attr:`col_offset` attributes. The :attr:`lineno` is the"
@@ -98,97 +109,97 @@ msgid ""
98109"UTF-8 internally."
99110msgstr ""
100111
101- #: ../../library/ast.rst:69
112+ #: ../../library/ast.rst:72
102113msgid ""
103114"The constructor of a class :class:`ast.T` parses its arguments as follows:"
104115msgstr ""
105116
106- #: ../../library/ast.rst:71
117+ #: ../../library/ast.rst:74
107118msgid ""
108119"If there are positional arguments, there must be as many as there are items "
109120"in :attr:`T._fields`; they will be assigned as attributes of these names."
110121msgstr ""
111122
112- #: ../../library/ast.rst:73
123+ #: ../../library/ast.rst:76
113124msgid ""
114125"If there are keyword arguments, they will set the attributes of the same "
115126"names to the given values."
116127msgstr ""
117128
118- #: ../../library/ast.rst:76
129+ #: ../../library/ast.rst:79
119130msgid ""
120131"For example, to create and populate an :class:`ast.UnaryOp` node, you could "
121132"use ::"
122133msgstr ""
123134
124- #: ../../library/ast.rst:88
135+ #: ../../library/ast.rst:91
125136msgid "or the more compact ::"
126137msgstr ""
127138
128- #: ../../library/ast.rst:97
139+ #: ../../library/ast.rst:100
129140msgid "Abstract Grammar"
130141msgstr ""
131142
132- #: ../../library/ast.rst:99
143+ #: ../../library/ast.rst:102
133144msgid "The abstract grammar is currently defined as follows:"
134145msgstr ""
135146
136- #: ../../library/ast.rst:106
147+ #: ../../library/ast.rst:109
137148msgid ":mod:`ast` Helpers"
138149msgstr ""
139150
140- #: ../../library/ast.rst:108
151+ #: ../../library/ast.rst:111
141152msgid ""
142153"Apart from the node classes, the :mod:`ast` module defines these utility "
143154"functions and classes for traversing abstract syntax trees:"
144155msgstr ""
145156
146- #: ../../library/ast.rst:113
157+ #: ../../library/ast.rst:116
147158msgid ""
148159"Parse the source into an AST node. Equivalent to ``compile(source, "
149160"filename, mode, ast.PyCF_ONLY_AST)``."
150161msgstr ""
151162
152- #: ../../library/ast.rst:117 ../../library/ast.rst:135
163+ #: ../../library/ast.rst:120 ../../library/ast.rst:138
153164msgid ""
154165"It is possible to crash the Python interpreter with a sufficiently "
155166"large/complex string due to stack depth limitations in Python's AST "
156167"compiler."
157168msgstr ""
158169
159- #: ../../library/ast.rst:124
170+ #: ../../library/ast.rst:127
160171msgid ""
161172"Safely evaluate an expression node or a string containing a Python literal "
162173"or container display. The string or node provided may only consist of the "
163174"following Python literal structures: strings, bytes, numbers, tuples, lists,"
164175" dicts, sets, booleans, and ``None``."
165176msgstr ""
166177
167- #: ../../library/ast.rst:129
178+ #: ../../library/ast.rst:132
168179msgid ""
169180"This can be used for safely evaluating strings containing Python values from"
170181" untrusted sources without the need to parse the values oneself. It is not "
171182"capable of evaluating arbitrarily complex expressions, for example involving"
172183" operators or indexing."
173184msgstr ""
174185
175- #: ../../library/ast.rst:139
186+ #: ../../library/ast.rst:142
176187msgid "Now allows bytes and set literals."
177188msgstr ""
178189
179- #: ../../library/ast.rst:145
190+ #: ../../library/ast.rst:148
180191msgid ""
181192"Return the docstring of the given *node* (which must be a "
182193":class:`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or "
183194":class:`Module` node), or ``None`` if it has no docstring. If *clean* is "
184195"true, clean up the docstring's indentation with :func:`inspect.cleandoc`."
185196msgstr ""
186197
187- #: ../../library/ast.rst:151
198+ #: ../../library/ast.rst:154
188199msgid ":class:`AsyncFunctionDef` is now supported."
189200msgstr ""
190201
191- #: ../../library/ast.rst:157
202+ #: ../../library/ast.rst:160
192203msgid ""
193204"When you compile a node tree with :func:`compile`, the compiler expects "
194205":attr:`lineno` and :attr:`col_offset` attributes for every node that "
@@ -198,82 +209,82 @@ msgid ""
198209"starting at *node*."
199210msgstr ""
200211
201- #: ../../library/ast.rst:166
212+ #: ../../library/ast.rst:169
202213msgid ""
203214"Increment the line number of each node in the tree starting at *node* by "
204215"*n*. This is useful to \" move code\" to a different location in a file."
205216msgstr ""
206217
207- #: ../../library/ast.rst:172
218+ #: ../../library/ast.rst:175
208219msgid ""
209220"Copy source location (:attr:`lineno` and :attr:`col_offset`) from *old_node*"
210221" to *new_node* if possible, and return *new_node*."
211222msgstr ""
212223
213- #: ../../library/ast.rst:178
224+ #: ../../library/ast.rst:181
214225msgid ""
215226"Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` "
216227"that is present on *node*."
217228msgstr ""
218229
219- #: ../../library/ast.rst:184
230+ #: ../../library/ast.rst:187
220231msgid ""
221232"Yield all direct child nodes of *node*, that is, all fields that are nodes "
222233"and all items of fields that are lists of nodes."
223234msgstr ""
224235
225- #: ../../library/ast.rst:190
236+ #: ../../library/ast.rst:193
226237msgid ""
227238"Recursively yield all descendant nodes in the tree starting at *node* "
228239"(including *node* itself), in no specified order. This is useful if you "
229240"only want to modify nodes in place and don't care about the context."
230241msgstr ""
231242
232- #: ../../library/ast.rst:197
243+ #: ../../library/ast.rst:200
233244msgid ""
234245"A node visitor base class that walks the abstract syntax tree and calls a "
235246"visitor function for every node found. This function may return a value "
236247"which is forwarded by the :meth:`visit` method."
237248msgstr ""
238249
239- #: ../../library/ast.rst:201
250+ #: ../../library/ast.rst:204
240251msgid ""
241252"This class is meant to be subclassed, with the subclass adding visitor "
242253"methods."
243254msgstr ""
244255
245- #: ../../library/ast.rst:206
256+ #: ../../library/ast.rst:209
246257msgid ""
247258"Visit a node. The default implementation calls the method called "
248259":samp:`self.visit_{classname}` where *classname* is the name of the node "
249260"class, or :meth:`generic_visit` if that method doesn't exist."
250261msgstr ""
251262
252- #: ../../library/ast.rst:212
263+ #: ../../library/ast.rst:215
253264msgid "This visitor calls :meth:`visit` on all children of the node."
254265msgstr ""
255266
256- #: ../../library/ast.rst:214
267+ #: ../../library/ast.rst:217
257268msgid ""
258269"Note that child nodes of nodes that have a custom visitor method won't be "
259270"visited unless the visitor calls :meth:`generic_visit` or visits them "
260271"itself."
261272msgstr ""
262273
263- #: ../../library/ast.rst:218
274+ #: ../../library/ast.rst:221
264275msgid ""
265276"Don't use the :class:`NodeVisitor` if you want to apply changes to nodes "
266277"during traversal. For this a special visitor exists "
267278"(:class:`NodeTransformer`) that allows modifications."
268279msgstr ""
269280
270- #: ../../library/ast.rst:225
281+ #: ../../library/ast.rst:228
271282msgid ""
272283"A :class:`NodeVisitor` subclass that walks the abstract syntax tree and "
273284"allows modification of nodes."
274285msgstr ""
275286
276- #: ../../library/ast.rst:228
287+ #: ../../library/ast.rst:231
277288msgid ""
278289"The :class:`NodeTransformer` will walk the AST and use the return value of "
279290"the visitor methods to replace or remove the old node. If the return value "
@@ -282,31 +293,31 @@ msgid ""
282293"may be the original node in which case no replacement takes place."
283294msgstr ""
284295
285- #: ../../library/ast.rst:234
296+ #: ../../library/ast.rst:237
286297msgid ""
287298"Here is an example transformer that rewrites all occurrences of name lookups"
288299" (``foo``) to ``data['foo']``::"
289300msgstr ""
290301
291- #: ../../library/ast.rst:246
302+ #: ../../library/ast.rst:249
292303msgid ""
293304"Keep in mind that if the node you're operating on has child nodes you must "
294305"either transform the child nodes yourself or call the :meth:`generic_visit` "
295306"method for the node first."
296307msgstr ""
297308
298- #: ../../library/ast.rst:250
309+ #: ../../library/ast.rst:253
299310msgid ""
300311"For nodes that were part of a collection of statements (that applies to all "
301312"statement nodes), the visitor may also return a list of nodes rather than "
302313"just a single node."
303314msgstr ""
304315
305- #: ../../library/ast.rst:254
316+ #: ../../library/ast.rst:257
306317msgid "Usually you use the transformer like this::"
307318msgstr ""
308319
309- #: ../../library/ast.rst:261
320+ #: ../../library/ast.rst:264
310321msgid ""
311322"Return a formatted dump of the tree in *node*. This is mainly useful for "
312323"debugging purposes. The returned string will show the names and the values "
@@ -316,7 +327,7 @@ msgid ""
316327"*include_attributes* can be set to ``True``."
317328msgstr ""
318329
319- #: ../../library/ast.rst:270
330+ #: ../../library/ast.rst:273
320331msgid ""
321332"`Green Tree Snakes <https://greentreesnakes.readthedocs.io/>`_, an external "
322333"documentation resource, has good details on working with Python ASTs."
0 commit comments